From: Christopher Dicely Date: 2008-04-20T04:58:50+09:00 Subject: Re: When are lambdas needed? On Thu, Apr 17, 2008 at 2:35 PM, Stedwick wrote: > I have seen many tutorials on the Internet explaining where lambdas > CAN be used, such as clever multiplication functions, but when are > they actually NEEDED? > > Sure, I can take a lambda and "pass it around" so to speak, but I can > call a function from anywhere too, right? Sure, you can call methods from almost anywhere. But you can't pass them around (unless you turn them into proc objects, in which case you are back to using lambdas.) And passing them around is necessary if you didn't write (and don't want to have to monkeypatch) all the library, etc., code from which you may want to perform a particular task. If those libraries are written to let you pass in proc objects, you are in good shape. > Can somebody give me an extremely useful, NOT complicated, example of > when lambdas are the absolute perfect solution to a problem? Callbacks.