lectura a través this, me vino a la broca en los valores por defecto para los argumentos de la función:defecto ordenar
fill = (container, liquid = "coffee") ->
"Filling the #{container} with #{liquid}..."
Eso es ordenada, pero luego intentó esto:
fill = (container="mug", liquid = "coffee") ->
"Filling the #{container} with #{liquid}..."
alert fill(liquid="juice")
y se lo inesperado alerta con "Filling the juice with coffee..."
. Entonces intenté esto:
fill = (container="mug", liquid = "coffee") ->
"Filling the #{container} with #{liquid}..."
alert fill(null, "juice")
y funcionó. Aunque no es lindo. ¿Hay una mejor manera, o es esta la manera idiomática de hacer esto?
se ve feo o tiene un sabor divertido, difícil de llamar – Ron