"Gennady" <gfb / tonesoft.com> schrieb im Newsbeitrag
news:40BE1DA0.9020409 / tonesoft.com...
>
> I am still using Ruby 1.6.8 and just came across a very strange thing
>
> ( nil || %r{abc} )

>> ( nil || %r{abc} )
=> /abc/

in 1.8.1 - I guess this is a log since fixed bug.  Better not use 1.6.8 any
more.  It's really outdated.

    robert


>
> yields false no matter what regular expression you use, while,
>
> ( nil || 3)
>
> yields 3, as it should.
>
> Is it a known issue for 1.6.8? I checked that everything works fine in
> 1.8.1.
>
> Here's more information from irb:
>
> [linux.gfbs:449]gfb-ems-session_1> ruby -v
> ruby 1.6.8 (2002-12-24) [i686-linux]
> [linux.gfbs:450]gfb-ems-session_1> irb
> irb(main):001:0> nil || 3
> => 3  # OK
> irb(main):002:0> nil || //
> => nil # WRONG
> irb(main):003:0> nil || %r{abc}
> => nil # WRONG
> irb(main):004:0> ( (nil) || (%r{abc}) )
> => nil # WRONG
> irb(main):005:0> nil || "abc"
> => "abc" # OK
> irb(main):006:0>
>
> Thank you,
> Gennady.
>
>