Reputation: 16187
I need to convert fixnums to strings. My solution is:
arr.map {|a| a.to_s}
Is there a better way?
Upvotes: 21
Views: 18363
Reputation: 108089
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.
Upvotes: 44