From: "Marvin Gülker" Date: 2009-12-30T20:48:00+09:00 Subject: Re: How to pass a function as parameter? Fritz Trapper wrote: > I want to pass a reference to function as parameter to another function > and execute the passed function. Somthing like this: > > def executer(func) > func(1) > end > > def test(x) > p x > end > > executer(test) > > How to write this correctly in ruby? Are you looking for the #method method? ---------------------------------------- irb(main):001:0> def a irb(main):002:1> puts "hello" irb(main):003:1> end => nil irb(main):004:0> def b(f) irb(main):005:1> f.call irb(main):006:1> end => nil irb(main):007:0> m = method(:a) => # irb(main):008:0> b(m) hello => nil irb(main):009:0> ------------------------------------------ Marvin -- Posted via http://www.ruby-forum.com/.