Set a variable and check equality in one line
<p>I'm creating a maze program to get some more practice in Java.  I have a method that moves the player, and it returns a <code>boolean</code> value if the move was successful (i.e. it didn't run into a wall).</p>

<p>Here is the method in question:</p>

<pre><code>public boolean move(Direction direction) {
    if(currentLocation == (currentLocation = maze.movePlayer(this, direction))) {
        return false;
    } else {
        return true;
    }
}
</code></pre>

<p>Obviously, this will always return false.  I was wondering if there is a way to check if <code>currentLocation</code> didn't change (or is equal to the returned value of <code>maze.movePlayer(...)</code> and set them equal if they aren't).  I don't know if it is possible to do this without calling the method twice or using a local variable.</p>

<p>I hope this makes sense!</p>
