put method Null safety

bool put(
  1. Piece piece,
  2. String square
)

Put piece on square

Implementation

bool put(Piece piece, String square) {
  /* check for piece */
  if (SYMBOLS.indexOf(piece.type.toLowerCase()) == -1) {
    return false;
  }

  /* check for valid square */
  if (!(SQUARES.containsKey(square))) {
    return false;
  }

  int sq = SQUARES[square];
  board[sq] = piece;
  if (piece.type == KING) {
    kings[piece.color] = sq;
  }

  updateSetup(generateFen());

  return true;
}