P
Pokkai Dokkai
how to find all members list(member functions & member variables for all
access specifiers like public, private and protected) ?
access specifiers like public, private and protected) ?
2007/10/26 said:how to find all members list(member functions & member variables for all
access specifiers like public, private and protected) ?
how to find all members list(member functions & member variables for all
access specifiers like public, private and protected) ?
__id__
how to find all members list(member functions & member variables for all
access specifiers like public, private and protected) ?
class A
def i
@i ||= 42
end
THUFIR said:Some rudimentary explanation please:
the def is to define a method?
it's a coincidence that the method name is "i" and the instance variable
has the same name, "I"?
the third line declares an instance variable, "i", what do the "||" do in
that line, please?
thanks,
Thufir
Yeap "def" is to define a method
It could be a coincidence... or not, depends on what you want to do with
this method... hum Here it's not a coincidence... this method return the
value of the instance variable i (it's a reader accessor) or if it's nil,
set it to 42 and return it.
basically || means "if it's nil do that ", then = assigns the value 42 to @i
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.