Skip to content

Comment on Yoda Conditionsparent

Comments

how would you write a yoda conditional with two variables? which is the yoda conditional (a == b), or (b == a)?

You can't if they're both mutable, since the whole idea of a yoda conditional is to put an immutable thing on the left side. What I meant was that you can't use them in that case, so it's a technique you can't use with 100% consistency.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.