Nil.match vs nil.=~

a = nil

if a =~ /a/

if a.match /a/
#why error ?

Because match is not defined on NilClass, but =~ is defined on Object,
which is the superclass of NilClass.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs