On Dec 6, 2006, at 8:05 AM, paul wrote:

> Probably I'm trying something impossible, but when giving default
> values for arguments to a method call, do I have to give default- 
> values
> for *all* arguments?

No, but all the arguments that don't have defaults must come before  
(to the left of) those that do.

> And also when giving default-values to all arguments, omitting
> arguments when calling the method doesn't seem to be a succes:
>
>    irb(main):001:0> class B
>    irb(main):002:1>   def b(c = 0, d = 1, e = 2)
>    irb(main):003:2>     puts c, d, e
>    irb(main):004:2>   end
>    irb(main):005:1> end
>    => nil
>    irb(main):006:0> B.new.b(1,2,3)
>    1
>    2
>    3
>    => nil
>    irb(main):007:0> B.new.b(1,,3)
>    SyntaxError: compile error
>    (irb):7: syntax error
>    B.new.b(1,,3)
>               ^
>            from (irb):7

Again, you can only leave out arguments that come after (to the right  
of) those you provide.

> Is it impossible or I'm I just coding it wrong?

You just need to switch strategies.  Use Ruby's simulated keyword  
arguments for something like this:

 >> def test(args)
 >>   puts args.values_at(:a, :b, :c)
 >> end
=> nil
 >> test :a => 1, :c => 2
1
nil
2
=> nil

Hope that helps.

James Edward Gray II