Re:Ruby 2.6
by mmahemoff on Monday December 24, 2018 @04:01PM
(#18754250)
Also, chaining is extremely concise. e.g. "products.map(&:cost).sort.last"
[ Parent
| on HN ]
I couldn't resist...
Your example could be improved by using "products.sort_by(&:cost).last"
I try to not use map because often there are methods that already implement filtering. Gotta love Ruby readability.
I think you need `products.sort_by(&:cost).last.cost` for the same result.