From: Chris Hulan Date: 2013-02-27T02:33:17+09:00 Subject: Re: undefined local variable or method `m' --20cf307f32644b319a04d6a3f951 Content-Type: text/plain; charset=ISO-8859-1 watch this: http://www.youtube.com/watch?v=iLxKNUFHAnY On Tue, Feb 26, 2013 at 12:05 PM, Love U Ruby wrote: > >> class Test > >> m=self > >> def self.show > >> print "hi" > >> end > >> def display > >> m.show > >> end > >> end > => nil > > Why does the below error come? can anyone help me here? > > >> foo = Test.new > => # > >> foo.display > NameError: undefined local variable or method `m' for > # > from (irb):7:in `display' > from (irb):11 > from /usr/bin/irb:12:in `
' > > -- > Posted via http://www.ruby-forum.com/. > > --20cf307f32644b319a04d6a3f951 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On Tue, Feb 26, 2013 = at 12:05 PM, Love U Ruby <lists@ruby-forum.com> wrote:
>> class Test
>> m=3Dself
>> def self.show
>> print "hi"
>> end
>> def display
>> m.show
>> end
>> end
=3D> nil

Why does the below error come? can anyone help me here?

>> foo =3D Test.new
=3D> #<Test:0x0000000106f9b8>
>> foo.display
NameError: undefined local variable or method `m' for
#<Test:0x0000000106f9b8>
=A0 from (irb):7:in `display'
=A0 from (irb):11
=A0 from /usr/bin/irb:12:in `<main>'

--
Posted via http://= www.ruby-forum.com/.


--20cf307f32644b319a04d6a3f951--