foo.display
NameError: undefined local variable or method m' for #<Test:0x0000000106f9b8> from (irb):7:indisplay’
from (irb):11
from /usr/bin/irb:12:in `’
Because m is an undefined local variable or method.
If you have the urge to do weird stuff like that, then make “m” a
Constant, class variable, instance variable, or method.
foo.display
NameError: undefined local variable or method m' for #<Test:0x00000000eb85e8> from (irb):18:indisplay’
from (irb):22
from /usr/bin/irb:12:in `’
I think something I am doing wrong,conceptually here. What is it,could
you tell me?
I think something I am doing wrong,conceptually here. What is it,could
you tell me?
Yes, I already told you only a couple of days ago:
You do not have the slightest idea how to properly define
a class with an instance variable.
My students learn that in their first two weeks.
Maybe a metaphor helps: it’s like you are trying to read
Shakespeare but you don’t even know 50 words of English.
So you have to ask us for the meaning of 9 out of 10 words
and still don’t get the meaning of the whole sentence,
let alone the complete play.
That sucks.
Learn the basics. You got some good references from us.
foo.display
NameError: undefined local variable or method m' for #<Test:0x0000000106f9b8> from (irb):7:indisplay’
from (irb):11
from /usr/bin/irb:12:in `’
Since your variable is m and not @m (instance scope) or @@m (class
scope) then it doesn’t exist when the display function is called.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.