Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Yoda condition

 

A Yoda condition [1] is a type of if-statement in which the the constant value (for example '6') is put first, so one can be sure that an unintentional assignment (for example 'if (6 = value)') is detected by the compiler.

 

 

 

 

 

Example

 

 

 

 

 

 

References

 

  1. The Dodgy Coder

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict