3 ms·
But it is absolutely unintuitive why it shouldn't be if mylist.length > 10
by oezi 3y ago
But it is absolutely unintuitive why it shouldn't be
if mylist.length > 10
- mixmastamyk 3y agoIf the length of mylist ... see how length comes first? Only unintuitive if you never spoke English or other european languages.
- AlchemistCamp 3y agoThis construction is something my French friend often does in English instead of using a possessive—the <property> of <thing>. As a native speaker of English, I’d just say, “if mylist’s length is more than 10”.
- jbergens 3y agoA really, really bad argument in my opinion. That thinking would lead us to Cobol.
- mixmastamyk 3y agoA really, really bad reply imho—see how useful that is?
- oezi 3y agoWith all other object oriented structures you would think that you want to do something with the mylist, thus you would first write down mylist. In Ruby I thus often write something such as: if mylist.empty?.! Because my line of thinking goes from the object to a function or attribute and then chains further along. Calling the `.!` method on the returned boolean object is very nice, because I don't have to go back to before mylist and insert the !-operator there.
- abenga 3y agoI haven't written any Ruby. Maybe one gets used to this after some time, but this honestly looks like it will enable you to write extremely clever and succinct code that makes perfect sense at the time, but a chore for anyone else to read and grok quickly (including the writer themselves a few weeks later). I could be wrong though.