Arrays • Exercise 5/6

Symbol to Proc

00:00
0
15 points

Instructions

Ruby has a powerful shorthand for calling a method on each element.

Instead of:
ruby
words.map { |w| w.upcase }

You can write:
ruby
words.map(&:upcase)

The &:method_name converts a symbol to a proc that calls that method.

Create a function lengths that returns the length of each string
in an array using the &:method syntax.

Your Code

Results

Click "Run Tests" to see results