null != null - any ideas on how to re-arrange the code or prevent this?
- by Alex
Currently debugging, and found an if-statement which for no (I thought...) reason gave me an NPE, obviously for a reason. Which seemed to be that the statement turned out to be if(false && (null != null || null != Color)).
if(destination != null && (destination.getPiece() != null || destination.getPiece().getColour() != pieceColour)) - the if-statement
Both destination can be null and piece can be. The getColour() method returns an attribute of type Color from piece, which must be null if the piece is null. The piece at destination has a different pieceColour attribute then the one in the if-statement.
Specifically, how do I re-arrange (destination.getPiece() != null) ?