Method Chaining and Symbols to Proc
Chain methods and use &:method as a shortcut for a block.
Example
words = %w[apple Banana cherry]
puts words.map(&:downcase).select { |w| w.length > 5 }.sort.join(", ")
puts (1..10).select(&:even?).map { |n| n * n }.sumResult
banana, cherry 220
Exercise
Shortcut block.
map(&:)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.