Brat allows you to pass in any number of “named arguments” to a function. Well, they are not really named arguments, but key-value pairs which get collected up into a single hash and passed to the function. This is Brat’s “implicit hash argument”. In fact, you could litter a function call with these key-value pairs all over, and they would still be collected up into a single hash.
Previously, this was the syntax, using symbols as keys:
This was then simplified (taking a hint from Ruby 1.9):
Now it is even better:
Like using function arguments without comma separaters, be careful when using variables as values, as they will see following arguments as their arguments. For example:
This code is parsed as:
This may or may not be what you want (probably not).
This allows some pseudo-Smalltalkish functions. For example, we could define if-then-else like so: