13. Lambda Syntax


#1

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

#2

this line:

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


#3

@stetim94 is right about that

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


#4

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


#7

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


#8