Nil || //

Why does this not work in Ruby 1.6:

[pbrannan@zaphod scripts]$ ruby -v -e 'p nil || //'
ruby 1.6.7 (2002-03-01) [i686-linux]
nil
[pbrannan@zaphod scripts]$ ruby-1.7 -v -e 'p nil || //'
ruby 1.7.2 (2002-07-13) [i686-linux]
//

Paul

[pbrannan@zaphod scripts]$ ruby -v -e 'p nil || //'

pigeon% /usr/bin/ruby -riis -ve 'puts dump; p nil || //'
ruby 1.6.7 (2002-03-01) [i686-linux]
puts(dump)
p(((nil ) || (//i)))
nil
pigeon%

// interpreted as a regexp

[pbrannan@zaphod scripts]$ ruby-1.7 -v -e 'p nil || //'

pigeon% ./ruby -rii -ve 'dump; p nil || //'
ruby 1.7.2 (2002-08-06) [i686-linux]
eval_tree
BLOCK
  NEWLINE <-e:1>
  VCALL dump
  NEWLINE <-e:1>
  FCALL p
    ARRAY
      OR
        NIL
        LIT //

//
pigeon%

  // interpreted as litteral

Guy Decoux

p.s.: iis must have a bug (it has inserted /i), this is really *bad* :slight_smile:

???, as this works:

batsman@kodos:~$ ruby -v -e ‘a=//; p nil || a’
ruby 1.6.7 (2002-03-19) [i386-linux]
//

Does this mean // is taken as nil in your example?

···

On Sat, Aug 10, 2002 at 01:50:51AM +0900, Paul Brannan wrote:

Why does this not work in Ruby 1.6:

[pbrannan@zaphod scripts]$ ruby -v -e ‘p nil || //’
ruby 1.6.7 (2002-03-01) [i686-linux]
nil


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

  • LG loves czech girls.
    LG: do they have additional interesting “features” other girls don’t have? :wink:
    #Debian

Why does this not work in Ruby 1.6:

[pbrannan@zaphod scripts]$ ruby -v -e ‘p nil || //’
ruby 1.6.7 (2002-03-01) [i686-linux]
nil
[pbrannan@zaphod scripts]$ ruby-1.7 -v -e ‘p nil || //’
ruby 1.7.2 (2002-07-13) [i686-linux]
//

No, it works, but completely different way.

> ruby-1.6 -e '$_ = ""; p nil || //' 
0
> ruby -e '$_ = ""; p nil || //'         
//

Namely 1.6.x treats Regexps in every conditional as implicit matching
to $_, whereas 1.7.x stops this special treatment because of an
argument almost same to yours.

The magic remains for such as `break if /^\s*$/’ construct, read the
code for more exact information :slight_smile:

···

In message 20020809125049.N11837@atdesk.com pbrannan@atdesk.com writes:


kjana@dm4lab.to August 10, 2002
Time is illusion, life is confusion.

My appologies. I do not understand your response.