title: Assign variable value inside if-statement
body: <p>I was wondering whether it is possible to assign a variable a value inside a conditional operator like so:</p>
  
  <p><code>if((int v = someMethod()) != 0) return v;</code></p>
  
  <p>Is there some way to do this in Java? Because I know it's possible in <code>while</code> conditions, but I'm not sure if I'm doing it wrong for the if-statement or if it's just not possible.</p>