From: James Coglan Date: 2009-03-20T20:39:49+09:00 Subject: Re: Passing a named function instead of a code block? --001636c5c0cca8e52904658b6989 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 2009/3/20 Paul Jungwirth > Okay, now how about when you want to reference a method on an instance? > For example: > > #!/usr/bin/env ruby > > class Adder > def initialize(n) > @n = n > end > > def use(x) > x + n > end > end > > > a = Adder.new(5) > > print [1, 2, 3, 4].collect(&method(:a.use)) > > This doesn't work. It looks like : binds tighter than .. But :(a.use) > doesn't work either. Any suggestions? a.method(:use) See docs for Object#method: http://ruby-doc.org/core/classes/Object.html#M000338 --001636c5c0cca8e52904658b6989--