13. Lambda Syntax

Hello everyone,
What am I doing wrong?

strings = ["leonardo", "donatello", "raphael", "michaelangelo"]
# Write your code below this line!
symbolize = lambda { |x| x.magic! }
# Write your code above this line!
symbols = strings.collect(&symbolize)

I get this error message:

undefined method `magic!' for "leonardo":String

this line:

you need to call .to_sym on your parameter, not magic!

1 Like

@stetim94 is right about that

This’s just and example symbolize = lambda { |x| x.magic! }

1 Like

I did the same thing, then realised .to_sym does the magic

2 Likes

A post was split to a new topic: 13. lambda syntax