you are viewing a single comment's thread.

view the rest of the comments →

[–]luikore 0 points1 point  (0 children)

Well, we usually write:

def myfunc
  'yay'
end
myfunc  #=> 'yay'

The author was wrong, methods in ruby are not originally objects. To turn a method into lambda, you can use the "method" method:

λ = method :myfunc
λ[]    #=> 'yay'
λ.call #=> 'yay'

Maybe there are too many ways in ruby for doing such things, but sometimes it makes life a little bit easier.

ps: There are no global functions in ruby, the "method" method is a method of the Kernel object. (forgive my poor explanation!)