Hi,
I am reading the tutorial at:
http://en.wikibooks.org/wiki/Programming:Ruby_Method_Calls
and I understand everything except this last method override code.
We had this,(line below) which is simple and we are overriding to make
it “better”
upcase_words = words.map {|x| x.upcase}
class Symbol
# A generalized conversion of a method name
# to a proc that runs this method.
#
def to_proc
lambda {|x, *args| x.send(self, *args)}
end
end
Voila !
words = %w(Jane, aara, multiko)
upcase_words = words.map(&:upcase)
So we are overriding the to_proc method with
lambda {|x, *args| x.send(self, *args)}
so in the lambda, the x in |x, args| is the same as the |x| in the
block (Jane, aara, multiko)(yes?, no?)
and the args in |x, args| is the symbol :ucase, (yes?, no?)
I don’t understand x.send(self, *args)
self is the symbol :ucase ?
but so is args ???
In my brain, at some point I get “jane.send(self, *args)”
I’m lost.
I do understand the concept of opening a class and overriding a
method, just not the details here.
Thank in advance