Proc and Lamda Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Which one the method to call the lambda?

A

my_lambda = -> { puts “Lambda called” }

a) my_lambda.call
b) my_lambda.()
c) my_lambda[]
d) my_lambda.===

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

times_two = ->(x) { x * 2 }
times_two.call(10)

Is this code valid?
What is the output of this code?

A

Its the other way of defining Lambda.

output
20

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
proc and lambda are supported by a class.
True or False? If so mention the class name
A

yes. Procedure or simply Proc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly