Yoda Conditions

November 14, 2012 Written By
	if  ( 5 == count)

Lately I picked up on this thing called Yoda Conditions. I started using this on a new project I’ve been working on. First it was a bit odd I must say, but once I got into it boy do I love to declare my conditions like this.

The big upside from this is that when you’re reading the code you actually see the expected result first. You can actually see that on the image example.

The term “Yoda Conditions” was coined by zneak a stackoverflow user.


Like it? Tweet it.

"Yoda Conditions" via @marcogmonteiro