Peña, Botp
12/24/2008 3:06:00 AM
From: Nasir Khan [mailto:rubylearner@gmail.com]=20
# irb(main):012:0> nil =3D~ /foo/
# =3D> false
#=20
# Should'nt it return nil instead?
depends on the beholder.
:~$ qri =3D~
---------------------------- Multiple choices:
Gem::Dependency#=3D~, Gem::Platform#=3D~, Object#=3D~,
REXML::Light::Node#=3D~, RegAnd#=3D~, RegOr#=3D~, Regexp#=3D~, =
String#=3D~
:~$ qri object#=3D~
--------------------------------Object#=3D~
obj =3D~ other =3D> false
--------------------------------
Pattern Match---Overridden by descendents (notably Regexp and
String) to provide meaningful pattern-match semantics.
so you probably want,
> /foo/ =3D~ nil
=3D> nil
and if failing is divine, try #match
> /foo/.match nil
=3D> nil
> nil.match /foo/
NoMethodError: undefined method `match' for nil:NilClass