Using Ruby, how do I convert all array values to a given type? -
i need convert fixnums strings. solution is:
arr.map {|a| a.to_s}
is there better way?
arr.map(&:to_s)
this uses spiffy new feature in ruby >= 1.8.7, "symbol proc" shortcut, , equivalent code in question.
Comments
Post a Comment