Array#=== (ps: bug in irb?)

Hello,

Just a thought:

class Array
def === obj
include? obj
end
end

(I couldn’t try it out in irb, though, because it chokes on the `===’.
Bug?)

Anyway, does anyone use Array#=== is it currently is? Or has this been
tried before?

Chris

$ cat array.rb
match = /(\w+) (\w+)/.match(‘foo bar’)[1…2]

case match
when [‘foo’, ‘bar’]
puts ‘foo bar’
else
puts “BUG!!!”
end

puts “changing Array#===”

class Array
def === obj
include? obj
end
end

case match
when [‘foo’, ‘bar’]
puts ‘foo bar’
else
puts ‘BROKEN!!!’
end
$ ruby array.rb
foo bar
changing Array#===
BROKEN!!!

···

Chris Pine (nemo@hellotree.com) wrote:

Hello,

Just a thought:

class Array
def === obj
include? obj
end
end

(I couldn’t try it out in irb, though, because it chokes on the `==='.
Bug?)

Anyway, does anyone use Array#=== is it currently is? Or has this been
tried before?


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04