V
vishy
Hi,
I am looking for some explanation for this ruby snippet.
class Symbol
def to_proc
lambda {|x, *args| x.send(self, *args)}
end
end
words = %w(Jane, aara, multiko)
upcase_words = words.map(&:upcase)
What I understand is that,:upcase is a symbol,and by appending
&,to_proc is fired.What happens next? What is x and *args in to_proc ?
thanks
I am looking for some explanation for this ruby snippet.
class Symbol
def to_proc
lambda {|x, *args| x.send(self, *args)}
end
end
words = %w(Jane, aara, multiko)
upcase_words = words.map(&:upcase)
What I understand is that,:upcase is a symbol,and by appending
&,to_proc is fired.What happens next? What is x and *args in to_proc ?
thanks