On 26.05.2007 23:37, Robert Dober wrote: > On 5/26/07, Robert Klemme <shortcutter / googlemail.com> wrote: > >> irb(main):001:0> def it_test(v) >> irb(main):002:1> (v+1).instance_eval do >> irb(main):003:2* return self if self < 10 >> irb(main):004:2> end >> irb(main):005:1> "nothing" >> irb(main):006:1> end >> => nil >> irb(main):007:0> it_test 0 >> => 1 >> irb(main):008:0> (0..10).map {|i| it_test i} >> => [1, 2, 3, 4, 5, 6, 7, 8, 9, "nothing", "nothing"] >> > That is something I am surprised about, b/c the intention was to have > an idiom for > return it if h(x) < 10 No, it's "return it if it < 10" with "it" being "v+1" in this case. > and > return it_test(h(x)) > really is not the same, right? It's not the same but I believe you misread the task. it_test is just a method to demonstrate the idiom in lines 2-4. m(int->int): x -> x+1 h(int->bool): x -> x<10 g(int->int): x -> x x: v (see also Greg's original posting) Kind regards robert