Methods Flashcards
Define method
a named block of parameterized code associated with one or more objects
Define method invocation
specifies the method name, the object on which it is to be invoked (sometimes called the receiver), and zero or more argument values that are assigned to the named method parameters.
What is the value of a method invocation expression?
the last expression evaluated in the method
Methods are objects. T/F?
False
It is possible to create an object from a method. T/F?
True
How are methods different from blocks?
They are named and do not have to be invoked with an iterator method.
What is it called when an object represents a block?
a proc
What are the two kinds of proc objects?
lamdas and procs
What do we mean when we say a proc object is a closure?
retain access to the local variables that were in scope when they were defined, even when the proc or lambda is invoked from a different scope.
What keyword is used to define a keyword?
def
What value is returned from a method if no expression follows the return keyword?
nil
When must an explicit return value be used?
When more than one value needs to be returned.
What is a singleton method?
A method defined for just a single object.
What keyword is used to undefine a method?
undef
undefine can be used to undefine a method is a subclass but not the parent class. T/F?
true