default method parameters


I have an method like this: def test(x, y='', z='')   puts "x=#{x} y=#{y} z=#{z}" end

and I want call with x and z parameters: test('x', z='z') output: x='x' y='z' z=''

How you can see, the Z value appears in Y parameter... and I want call just with X and Z parameters

Thanks a lot!

Cassiano Roloff RS - Brazil

You can always simulate it by passing in a hash:

def test(in_hsh={}) puts "x=#{in_hsh['x']} y=#{in_hsh['y']} z=#{in_hsh['z']}" end

test({'x' => 'x', 'z' => 'z')

Cassiano Roloff wrote: