I wrote a comment suggesting an alternate syntax for the Ruby "safe navigation" operator (aka "syntax for try") https://bugs.ruby-lang.org/issues/11537#note-23 …
@nerdblogpl I find it easier to read than u.?profile.?thumbnails.?large, which reads like a mishmash to me & visually conflicts w/ ? methods
-
-
@wycats unfortunately I agree. I'm still worried it'll lead to unintentional errors with more complex conditionals because it's non-obvious -
@nerdblogpl It would probably lead to parentheses in complicated situations, but that seems ok. -
@wycats (u && .avatar && .large) && (u && .avatar && .small) doesn't look so sexy anymore :) -
@nerdblogpl syntax error. -
@wycats this one should/could actually work like u.try(:avatar).try(:large) && u.try(:avatar).try(:small) -
@nerdblogpl oh I missed what you did there. The reason it's getting complex is that it's describing something that isn't a one-liner. -
@nerdblogpl if you wrote it out in English it would be long, and therefore justifies a couple lines imo. -
@wycats I see your point, though I'm pretty sure less experienced developers will end up using such a horrible syntax anyway :) - 1 more reply
New conversation -
-
-
@wycats how should for example u && .avatar && (.small || .large) work? Or what if you want to do u.avatar.small && u.avatar.large ? -
@nerdblogpl syntax error.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.