May-09-2017, 09:42 PM
It's because parenthesis are optional for calling methods in ruby, so for times like this, it isn't obvious whether you're passing arguments to path.length(), or if you're operating on it's result. You can add parenthesis to all three of those, and they'll all do the same thing.
Also, the do loop takes a function, the |x| syntax is ruby's version of lambda. It's been a while since I've ruby'd, but I'd be willing to be the do had an "end" afterward, with some sort of function body that used the index.
Ruby's an alright language.
Also, the do loop takes a function, the |x| syntax is ruby's version of lambda. It's been a while since I've ruby'd, but I'd be willing to be the do had an "end" afterward, with some sort of function body that used the index.
Ruby's an alright language.