Hello,

2011/10/19 Joshua Ballanco <jballanc / gmail.com>:
> =A0 =A0 # Ruby 2.0 proposal:
> =A0 =A0 def foo(a: 1, b: 2, c: 3)
> =A0 =A0 =A0 =A0 puts [a, b, c]
> =A0 =A0 end
> =A0 =A0 foo(a: 'one', b: 'two', c: 'three') #=3D> ["one", "two", "three"]
> =A0 =A0 # Currently in MacRuby:
> =A0 =A0 def foo(a: first, b: second, c: third)
> =A0 =A0 =A0 =A0 puts [first, second, third]
> =A0 =A0 end
> =A0 =A0 foo(a: 'one', b: 'two', c: 'three') #=3D> ["one", "two", "three"]


Interesting.  Matz, which do you prefer?


Could you tell me the detail of MacRuby's keyword
arguments?
What's happen when all arguments are not given?

  def foo(a: first, b: second)
    p [first, second]
  end
  foo(a: 1) #=3D> [1, nil] ??
            # or
            #=3D> ArgumentError ??

Is there a feature to get the rest keyword arguments?

  def foo(a: first, b: second, **h)
    p [first, second, h]
  end
  foo(a:1, b:2, c:3, d:4) #=3D> [1, 2, {:c=3D>3, :d=3D>4}]

How about this?

  def foo(x, a: first, b: second)
    p [x, first, second]
  end
  foo(a: 1, b: 2) #=3D> [{:a=3D>1, :b=3D>2}, nil, nil] ??
                  # or
                  #=3D> wrong number of arguments ??

--=20
Yusuke Endoh <mame / tsg.ne.jp>