Home > RUBY > dari Lambda jadi Doing, dari Tiada jadi Ada

dari Lambda jadi Doing, dari Tiada jadi Ada

March 7, 2008

We often do this in our spec code, lambda { “do something” }.should change(object) then one invisible samurai soul next to me said : “aliasing this lambda to be doing is more readable instead”.

Me: “Well that won’t be ruby syntax anymore :-P and it’s not very familiar then to other rubyists”.

Him: “’should’ syntax is not general ruby either”.

Me: “Yeah that’s because of ruby metaprogramming.”.

Me:

irb
>> module Kernel
>>   alias :doing :lambda
>> end
=> nil
>> a = doing { "tes" }
=> #
>> a.call
=> "tes"
>> exit

Me: “Ha, your idea works! :-P”

Him: “Well it’s not my idea actually I read it someone’s idea somewhere”

Me: “:-P our rake stats is getting thinner”

Note: Let me know if you find this idea, you like it or you hate it, feel free to comment. Comments should go in this blog post/thread comment, not via Skype, YM, etc =)) :-P doing C++ / Smalltalk situp again for the sake of DP by GoF! again… again… -_-

  1. March 14, 2008 at 11:25 am | #1

    Antara Ada dan Tiada, hehehehe

  2. wharsojo
    March 25, 2008 at 11:11 am | #2

    jengah gue ama lambda!
    walau uda jelas & tau artinya tetep aja ndak mudeng mudeng,

    Great dah ama simple tipnya…. :)

    wharsojo

    tutorial lambda asik

Comments are closed.