Oops, I pasted the code wrong. What I wanted to do was generate every move from the current position of the rook up to a piece, and including the piece if the piece is a black piece. See updated post.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I agree the loop would look worse. However, in this case all you are doing is finding the first piece and if it's white calling a method, right?
So you could do something like
where the
findFirstPiece
would find the firstrow
value that is either a white or a black piece, returning -1 if no such value was found.Oops, I pasted the code wrong. What I wanted to do was generate every move from the current position of the rook up to a piece, and including the piece if the piece is a black piece. See updated post.