I'm looking for a clean way to write a function that allows me to choose
which parameter to solve for assuming all others are known. Is it good
design to do something like this: ?

class Foo
  def initialize(x, y, z)
    @x, @y, @z = x, y, z
  end

  def function(var)
    if @x.nil?
      @x = var
    elsif @y.nil?
      @y = var
    else
      @z = var
    end
    @x + @y + @z
  end

end

z = Foo.new(1, 2, nil)
z.function(3)
=> 6
??
-- 
Posted via http://www.ruby-forum.com/.