A
Arlen Cuss
[Note: parts of this message were removed to make it a legal post.]
Hi,
It's different with blocks:
irb(main):029:0> def this_that(val=nil)
irb(main):030:1> puts "infinite?" if val.nil?
irb(main):031:1> yield 42
irb(main):032:1> end
=> nil
irb(main):033:0> this_that {|a| p a}
infinite?
42
=> nil
irb(main):034:0> this_that(9) {|a| p a}
42
=> nil
irb(main):035:0>
Arlen
Hi,
I was thinking about that too, but as far as I understand it Ruby only
allows optional arguments to be the last arguments - i.e. the "n"
parameter would have to appear after the code block. And that would
look strange : forkmap{ code }(4).
It's different with blocks:
irb(main):029:0> def this_that(val=nil)
irb(main):030:1> puts "infinite?" if val.nil?
irb(main):031:1> yield 42
irb(main):032:1> end
=> nil
irb(main):033:0> this_that {|a| p a}
infinite?
42
=> nil
irb(main):034:0> this_that(9) {|a| p a}
42
=> nil
irb(main):035:0>
Arlen