(C++) Yoda condition

February 24, 2017 · View on GitHub

 

 

 

 

 

(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

 

  • Yoda condition example 1: basics

 

 

 

 

 

References

 

  1. The Dodgy Coder

 

 

 

 

 

 

Contents

  1. 1Example
  2. 2References