What is YODA Condition in Programming language

0 votes
10 views
asked Aug 10 by anonymous
Hi

  Can any one explain about YODA Condition

1 Answer

0 votes
answered Aug 10 by admin (8,115 points)

Usually a conditional statement would be written as:

if ( $value == 42 ) { /* ... */ }
// Reads like: "If the value is equal to 42..."

Yoda conditions describe the same expression, but reversed:

if ( 42 == $value ) { /* ... */ }
// Reads like: "If 42 equals the value..."


More info : Yoda Condition
...