I don't understand the if(!move(tile))
condition in pset3. Can anyone please explain it to me? Can I change this code?
1 Answer
if (!move(tile))
is a shortcut for
bool didItMove = move(tile);
if (didItMove == false)
{
// do this
}
In other words, it first calls the move function (that you are writing), passing in the tile (the number that the user entered). If that function returns false (i.e., it was an invalid move), then do whatever is in the statement following.