Nul*_*uli 2 ruby ruby-on-rails
users_allowed_to_be_viewed.map {|u| "#{u.id},"}
Run Code Online (Sandbox Code Playgroud)
但是这给了 1,2,3,
什么是一个简短的方法来获得类似的东西 1,2,3
数组?
来自http://ruby-doc.org/core/classes/Array.html
array.join(sep=$,) ? str
Returns a string created by converting each element of the array to a string, separated by sep.
[ "a", "b", "c" ].join #=> "abc"
[ "a", "b", "c" ].join("-") #=> "a-b-c"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2620 次 |
| 最近记录: |