I ne开发者_如何学Goed to convert fixnums to strings. My solution is:
arr.map {|a| a.to_s}
Is there a better way?
arr.map(&:to_s)
This uses a spiffy new feature in Ruby >= 1.8.7, the "symbol to proc" shortcut, and is equivalent to the code in your question.
精彩评论