Joined May 2011

Luca Guidi

Senior Developer at Litmus
Senior Developer
Rome, Italy

Posted to Constants in CoffeeScript over 1 year ago

Thanks for the clarification. Was this syntax introduced recently? IIRC, my first attempt was written like your last example, but it didn't worked.

Correct syntax highlight for this protip:

It looks like the Ruby syntax here is broken.

Posted to Ruby implicit coercion over 1 year ago

@apecox In this case, if you omit 0, you're forced to implement #+ in InvoiceValue::Entry. This because the loop don't have an initial value and tries to call #+ on all the entries.

Instead, with that explicit argument the VM tries to do 0.+(entry), that means a Fixnum with an InvoiceValue::Entry so asks to the last one to coerce itself, and the trick works.

So, there is a win in having that 0.

1,313 Karma
93,097 Total ProTip Views