From: Justin Collins Date: 2008-01-19T04:11:50+09:00 Subject: Re: passing method references in python & ruby Rados�aw Bu�at wrote: > In python when you use method name without parenthesises you get > method reference. In Ruby it won't work beacuse method can be called > without parenthesises (and Ruby programmers love it :)). If you want > to get method reference you can use method(:you_method_name) and you > get reference to Method instance. Later you can just call 'call' > method and pass some parameters. Direct traslation of your program to > Ruby looks like: > > def firstWay(arg1, arg2) > return 'Tastes great.' > end > > def secondWay(arg1, arg2) > return 'Less filling.' > end > > def doStuff(whichway, first_arg, second_arg) > return whichway.call(first_arg, second_arg) > end > > puts doStuff(method(:firstWay), nil, nil Ah, that's the one I was looking for. Then you can do: def doStuff(whichway, first_arg, second_arg) whichway[first_arg, second_arg] end -Justin