4 ms·
While I'm not against having some of this stuff written down, Ruby purposely adopts Perl's TMTOWTDI philosophy. So, using the while-loop approach is perfectly v
by thenduks 17y ago
While I'm not against having some of this stuff written down, Ruby purposely adopts Perl's TMTOWTDI philosophy. So, using the while-loop approach is perfectly valid.
Ruby beginners should use whichever way they find most agreeable and evolve their view of the language as they go. Reading code written by other people (respected rubyists, as you say) is a great (and, the recommended) way to pick up new tricks to improve your code with.
IMO, that's the way it should be. There's no reason to list every single little tip ('use inject instead of an external accumulator') somewhere since I wouldn't expect a beginner to read through all that anyway.
When I learned Python several years ago I didn't know PEP's existed for ages, I figured it out myself and I think I'm a better programmer for it.
- mechanical_fish 17y agoThere's no reason to list every single little tip ('use inject instead of an external accumulator') somewhere since I wouldn't expect a beginner to read through all that anyway. They might not read it on day one. But they will find themselves reading it via Google after they read a line of code (written, perhaps, by a respected Rubyist) that uses inject and are trying to figure out how the idiom works and where it should be used. And, if they're lucky and they've found some fairly clear and concise docs, they might bookmark that page, or even read the rest of the page while they're there, thus saving themselves anywhere from 20 to 100 future trips to Stack Overflow. ("What is this thing with the hash that we use to pass options? What is this oddball "names.map(&:upcase)" syntax? What does "class << self" mean? How come my colleagues laugh bitterly when I try to use Rails fixtures?")
- benofsky 17y agoMy point exactly.