display and collect functions will work the same here.
int_array = [1, 2, 3] str_array = int_array.map { |i| i.to_s } => str_array = ['1', '2', '3']
You can get this with a single line:
array = [1, 2, 3] array.map! { |i| i.to_s }
and you can use a really cool shortcut for proc: ( https://stackoverflow.com/a/167295/ )
array = [1, 2, 3] array.map!(&:to_s)
Idan Wender Jul 09 '13 at 12:13 2013-07-09 12:13
source share