+ 1

Ruby closures?

Hey! Need some help in understanding closures in Ruby. How do i access a variable from outside the method without yeilding it to a lambda? I just don't get it. Just returning its value doesn't seem to work.

15th May 2017, 6:30 PM
Irhen Petukhova
Irhen Petukhova - avatar
2 Antworten
+ 1
well, here's the answer: useanother variable assigning the result of the method to it. no closures needed. and about that closures: a closure is a proc or a lambda that remembers the lexical scope it was defined in even if it's called from outside that scope and also it can be passed around as an argument to other metods. have fun!
27th May 2017, 10:47 AM
Irhen Petukhova
Irhen Petukhova - avatar
+ 1
come on people!)
19th May 2017, 4:12 PM
Irhen Petukhova
Irhen Petukhova - avatar