From: "Thomas B." Date: 2008-09-21T03:14:44+09:00 Subject: Re: Question about Mixins and calling a method Carlos Ortega wrote: > 1) Is it possible to invoke a method with a "<<" notation ? It is not 'invoking a method with "<<" notation,' it is simply calling the method named observers without any arguments, and then calling << on the result of the method. This is equivalent to: (@observer_list||=[])< On the other side while reviewing the "observers" method, I noticed that > there is no parameter in its definition: Parentheses can be skipped both in definition and in call of a methods, if there are no parameters. > 2) Same situation happens in the "notify_observers" method, in it I can > invoke "observers.each" although it is not defined anywhere. Why can I > do that? Again, this is a call to the method observers, and then a call to the method each of the result you got. The method observers never returns nil, because it either initialises or just returns the already initialised @observer_list. The instance variable @observer_list itself is not defined anywhere though, because you don't have to declare instance variables in any way. Simply if you try to read a variable for the first time, it returns nil if the variable has not been assigned before. You can read more about classes and their features here: http://al2o3-cr.blogspot.com/2008/08/class-class.html TPR. -- Posted via http://www.ruby-forum.com/.