So defining the 'second' method like so:
def Array.second
self[1]
end
is the same is making the singleton class like below.
Class << Array
def second
self[1]
end
end
Gotcha.
Thanks for the help! =)
Gary Wright wrote:
> On Dec 21, 2007, at 6:51 PM, Ryan Lewis wrote:
> In this example, I opened up the singleton class associated
> with 'a' and defined a new method, second, that returns the
> second element of the array. As you can see, this method
> is only available to that one particular array and not to
> all array's in general.
>
> Gary Wright
--
Posted via http://www.ruby-forum.com/.