I know there are already a lot of questions about self
, but I just wanted to make sure I've understood it.
def buttonPressed
@action.call(self)
end
In this code, self
refers to @action
(because @action
is the receiver of the call method). Is that right?
{ songList.start }
If the proc object has no parameters like in this case, why give prc.call self
as parameter?
I. Outside of a class, self
returns main
of type Object
. Inside a class, it will return the current instance of the class.
II. In the case of this particular block, there is indeed no need for self
to be passed, but passing self
means you can also potentially have action
s that can access self
.