JavaScript

Do in Coffee

Coffee did me in this afternoon.

do draw = (ratio = 0) ->

I thought this meant that I’ve defined a function where ratio is always default to 0, and then called it for the first time.

Nope.

The actual output:

(draw = function(ratio) {})(0)

Only the first DO call took advantage of the default ratio. So if you want default value, leave out the pre-do and just call it after it’s properly defined.

Standard