2008/4/1, aidy <>:
> On 31 Mar, 16:56, Robert Klemme <shortcut...@googlemail.com> wrote:
>
> > The method invokes the block and uses the result to determine what to
> > do (if or else).
> >
> > Does that help?
>
> Surely does. Thanks Robert, your a linguist.
Hm, not sure whether that was irony or not.
Maybe this helps:
irb(main):001:0> def test(yes,no)
irb(main):002:1> if yield
irb(main):003:2> puts yes
irb(main):004:2> else
irb(main):005:2* puts no
irb(main):006:2> end
irb(main):007:1> end
=> nil
irb(main):008:0> test("ok", "not ok") { 1 > 2 }
not ok
=> nil
irb(main):009:0> test("ok", "not ok") { 1 < 2 }
ok
=> nil
irb(main):010:0> test("ok", "not ok")
LocalJumpError: no block given
from (irb):2:in `test'
from (irb):10
from :0
irb(main):011:0>
Kind regards
robert
--
use.inject do |as, often| as.you_can - without end