title: How can Polymorphism replace an if-else statement inside of a loop?
body: <p>How can polymorphism replace an if-else statement or Switch inside of a loop? In particular can it always replace an if-else? Most of the if-thens I use inside of loops are arithmetic comparisons. This question is spawned from this <a href="https://stackoverflow.com/questions/519422/what-is-the-best-way-to-replace-or-substitute-if-else-if-else-trees-in-programs/519447#519447">question</a>.</p>
  
  <pre><code>int x;
  int y;
  int z;
  
  while (x &gt; y)
  {
       if (x &lt; z)
       {
           x = z;
       }
  }
  </code></pre>
  
  <p>How would this work with polymorphism?<br>
  NOTE: I wrote this in Java but am interested in this for any OOL.</p>