Talk:Ruby Programming/Syntax/Method Calls

The ampersand (&)
I'm starting to learn Ruby and I think there is a mistake in the section about the ampersand. The redefinition of to_proc in class Symbol defined as

def to_proc lambda {|x, *args| x.send(self, *args)} end

doesn't work in my Ruby version 1.8.

What works is this:

def to_proc lambda {|*args| self.send(self, *args)} end

I am not sure if the first version worked in any of the previous releases of Ruby?

I would like to change it, but I would really appreciate someone checking if the new code is really 100% correct.

--filu 17:51, 7 April 2007 (UTC)

OK, the mistake is mine. The version of to_proc method found in the article indeed works, for method calls such as is the case with the upcase. However my version works for function calls, such as

def fun_upcase( s ) s.upcase end which in turn cannot be combined with the original to_proc.

Maybe this should be clarified in the text of the article.

--filu 19:31, 7 April 2007 (UTC)

Great Explanation
Wow what a wonderful explanation of Proc and Blocks. I was struggling with these when doing Rails project. Now everything seems to make sense and is clear. 155.94.62.223 (discuss) 20:53, 14 February 2012 (UTC)

Pasted blog post
In 2006 a blog post was pasted in. It arguably helps the page's content, and it's better than nothing, but it still needs copy-editing as it still reads as a blog post and not as part of a book. --Blaisorblade (discuss • contribs) 10:27, 15 May 2016 (UTC)