|
|
|
|
|
by parennoob
3752 days ago
|
|
In this thread are literally 300 comments saying "Huh, I don't even Ruby, and I understood it", thereby (in my opinion) completely proving the point. It's exactly because people pull this sort of thing "Hey, it was really easy to understand for me, how about you?" that I have seen developers feel compelled to put clever oneliners in codebases. Clever oneliners that later end up causing problems for whatever unluckly newbie has to troubleshoot their edge cases. Just stop it, and unless you're on a word budget or this drastically improves performance, do something sensible that looks like the pseudocode: for word in sentence.split(' '):
word.capitalize_first_letter
(If you want to be all functional, by all means use a map instead.)So I don't have to deal with the case where your clever function barfs on (hypothetical example, don't think this happens with the current code) the special case where there is a space between the last word and a period that ends the sentence; and you're trying to capitalize the period. [Edit: As expected, looks like this code fails with even common graphemes. Which is fine, but is an argument towards at least trying to make it more comprehensible.] |
|
The code is not written for newbies. It never will be. That's why they're 'newbies' and not 'professionals'.