Ordenação de parâmetros de função padrão
Lendo atravésesta, Cheguei ao bit em valores padrão para argumentos de função:
fill = (container, liquid = "coffee") ->
"Filling the #{container} with #{liquid}..."
Isso é legal, mas tentei o seguinte:
fill = (container="mug", liquid = "coffee") ->
"Filling the #{container} with #{liquid}..."
alert fill(liquid="juice")
e recebi o alerta inesperado com"Filling the juice with coffee..."
. Então eu tentei isso:
fill = (container="mug", liquid = "coffee") ->
"Filling the #{container} with #{liquid}..."
alert fill(null, "juice")
e funcionou. Não é bonito embora. Existe uma maneira melhor, ou é a maneira idiomática de fazer isso?