3 ms·
How is computing a weekday where the caller (and reader) must know that Monday=0 not cryptic?
by heartbreak 4y ago
How is computing a weekday where the caller (and reader) must know that Monday=0 not cryptic?
- throwawaymaths 4y agoI think the if being an infix operator is a bit "cryptic". I mean IMO it is easier to read - and in reality it's not a problem, because it's pretty unambiguous what's going on, but some people get annoyed by "oh you can do that in ruby?" Trigger that happens the first few times you see it. Probably same with fields/methods with a postfix ?
- dragonwriter 4y ago> Probably same with fields/methods with a postfix ? It's not a “postfix ?”, it's literally just “?” being part of the identifier name. (It's convention for methods that are boolean predicates.) Also, Ruby doesn't have fields. (It has instance variables, but they don't have dotted access, so they aren't in the same namespace as methods of the same object the way fields are.)
- throwawaymaths 4y agoIt's a postfix sigil, even if it's part of the identifier name. You're not allowed to put ? in the middle of an identifier. (I use ruby and elixir, so this is second nature to me. It might not be for others). I'm aware ruby doesn't have fields, I called it fields/methods because it's a method in ruby but people in other languages will read it as a field, which it is, a good percentage of the time.
- remram 4y agoEspecially when other systems like cron have used Monday=1 forever
- mod 4y agoI agree that's a little weird, but for me the consequence of it is small. I'm going to catch that bug quickly. When Ruby does a magic import, that would sometimes cost me a lot of time tracking it down when I first started with Ruby. I don't remember it being a big deal anymore after a couple of years. (I like both languages)