From: Charles Steinman Date: 2005-07-31T17:26:03+09:00 Subject: Re: Higher Order Functions Nickolay Kolev wrote: > in fruby.rb: > > module Functional > > def Functional.every(f, lst) > lst.collect { |element| f(element) } > end > > end > > in test.rb: > > require 'fruby' > > def times_two(x) > x * 2 > end > > p Functional.every(:times_two, [1,2,3]) > > > And I get this: > > undefined method `f' for Functional:Module (NoMethodError) > > How do I pass the times_two function to the module method? p Functional.every(method(:times_two), [1,2,3] And in Functional, it would be lst.collect { |element| f.call(element) } Just the token ":times_two" specifies a symbol. This symbol could represent anything -- a method, a constant, a variable, nothing at all -- so you use #method to get the method from the current context with a corresponding name. As a side note, I assume you realize that this is exactly the sort of thing blocks are for, right?