another nil concern

N

Nasir Khan

[Note: parts of this message were removed to make it a legal post.]

irb(main):012:0> nil =~ /foo/
=> false

Should'nt it return nil instead?

BR
nasir
 
P

Peña, Botp

From: Nasir Khan [mailto:[email protected]]=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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top