From: Paul Lutus Date: 2006-09-07T10:50:07+09:00 Subject: Re: multi-def docs? YAD wrote: > I thought Ruby allows you to define similar functions in parallel by > putting the parts that differ together in square brackets. Is there > some online documentation for that? I haven't been able to find it yet. What follows is only approximately like what you are describing. Maybe it will give you some ideas: #!/usr/bin/ruby class Demo def initialize @op_hash = { "+" => Proc.new { |y,x| y + x }, "-" => Proc.new { |y,x| y - x }, "*" => Proc.new { |y,x| y * x }, "/" => Proc.new { |y,x| y / x } } end def perform(y,x,m) @op_hash[m].call(y,x) end end demo = Demo.new puts demo.perform(1.0,3.0,"/") Output: 0.333333333333333 -- Paul Lutus http://www.arachnoid.com