Skip to main content

Posts

Showing posts from November, 2022

Yoda conditions in java

  In programming jargon ,  Yoda conditions  (also called  Yoda notation ) is a programming   style  where the two parts of an expression are reversed from the typical order in a conditional statement . A Yoda condition places the constant portion of the expression on the left side of the conditional statement. Usually a conditional statement would be written as: if ($value == 42) { /* ... */ } // Reads like: "If the value equals 42..." Yoda conditions describe the same expression, but reversed: if (42 == $value) { /* ... */ } // Reads like: "If 42 equals the value..."