Here is what I do quite often in Python:
simple_call = lambda name: extract(some[fairly][hidden], name)
result1 = simple_call('myname')
result2 = simple_call('yourname')
result3 = simple_call('hisname')
This is really handy if you have to extract some data from some complex data structure or some strange API repeatedly.
Is there a way to do the same thing in Ruby?
Short answer: No. The closest thing is:
Why? Because parenthesis in Ruby are optional. Then, you need to tell ruby to call the method. For example, in Python you could do:
And you are assigning the lambda to
another_simple_call. But in Ruby there would be no way to know if you are assigning or calling simple_call with zero arguments.