2008/4/18, Marc Heiler <shevegen / linuxmail.org>: > > lambda are perfect anytime you want a context sensitive result and > > don't want to code everything in one massive global scope. > > > My problem with lambda's is that I have a hard time to find a > real use case for them. I am not sure of some use case with > lambda {} that brings a definite advantage over i.e. just > using some special object or simple method. Technically, you can replace every lambda with an class and an instance thereof. The difference is that the lambda is syntactically and semantically more lightweight. To add another example, Rake tasks store away lambdas. my_lib_version = "1.0.2" task :tgz do sh "tar -czf my_lib-#{my_lib_version}.tgz lib" end Assuming a Ruby-like language without lambdas, we'd get this "pure OO" Rakefile: class TgzTask def initialize(version) @version = version end def execute sh "tar -czf my_lib-#@version.tgz lib" end end my_lib_version = "1.0.2" task :tgz, TgzTask.new(my_lib_version) All context we need in our method (local variables, eventually the current "self") has to be explicetely passed to the constructor, which has to initialize our object etc. Rake would loose all its appeal. Stefan