Joined May 2011
·
Posted to
TIL Ruby variables string interpolation
over 1 year
ago
Correct syntax highlight for this protip:
https://gist.github.com/jodosha/7410007
Posted to
TIL Ruby variables string interpolation
over 1 year
ago
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
.
Achievements
1,313 Karma
194,774 Total ProTip Views

24PullRequests Participant
Sent at least one pull request during the first 24 days of December 2014

T-Rex
Have at least one original repo where C is the dominant language

Beaver
Have at least one original repo where go is the dominant language

Forked 100
Have a seriously badass project that's been forked at least 100 times

Forked 50
Have a project with a thriving community of users that's been forked at least 50 times

Forked 20
Have an established project that's been forked at least 20 times

Altruist
Increase developer well-being by sharing at least 20 open source projects

Walrus
The walrus is no stranger to variety. Use at least 4 different languages throughout all your repos

Ashcat
Make Ruby on Rails better for everyone by getting a commit accepted

Honey Badger
Have at least one original Node.js-specific repo

Octopussy
Have a repo followed by a member of the GitHub team

Lemmings 100
Write something great enough to have at least 100 watchers of the project

Forked
Have a project valued enough to be forked by someone else

Charity
Fork and commit to someone's open source project in need

Mongoose 3
Have at least three original repos where Ruby is the dominant language

Mongoose
Have at least one original repo where Ruby is the dominant language
Thanks for the clarification. Was this syntax introduced recently? IIRC, my first attempt was written like your last example, but it didn't worked.