On 23 January 2016 at 16:12, stepharo <[email protected]> wrote:
> If you have
>> mother1 := foo:(bar:zork:fork)
>> mother2 := foo:bar:(zork:bork:)
>>
> I'm not sure that this is allows in the same class. We should check that
> in Python or ruby.
>
In Ruby:
def m(x=42, y=51)
→ calling m(3) gets x=3, y=51 (the given arguments are passed into the
leftmost parameters first)
def m(options)
→ calling m( { x: 3, y: 4 } ) or m( x: 3, y: 4 ) gets options = { x: 3, y:
4 }
So, a dictionary magically created because you passed something that either
was already a dictionary, or used the syntax of dictionary key/value pairs.
If you need default values for known keys, you take a default dictionary
and override its contents using
http://www.rubydoc.info/stdlib/core/Hash%3Aupdate
In Python I think it's more like the first Ruby alternative, except
arguments can be named (so those bypass the left-to-right assignment order)
--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet