Sunday, November 16, 2008

Use join method to merge Array into string

If you are a Ruby/Ruby on Rails developer.
Some times you need to concatenate/ merge Array elements into String, so its good to use join (Array method).

users_id =
#Add some ids into array, so it becomes,
users_id = [1001,1002,1003,1004,1005]
#Now use need all users ids in to lets say in query so just do,
#users_id.join(",") this will return String type object having users ids
# "1001,1002,1003,1004,1005"

No comments: