arr = [[a,1], [b,3], [c,2]]
How can I convert the above array into this below:
[1,3,2]
Use map
& last
:
arr.map(&:last) #=> [1,3,2]
this is equivalent to the longer
arr.map { |o| o.last }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With