We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For example, calling chessboard(-1) will lead to endless recursion and eventually stack overflow.
def chessboard(count: Int): Image = { val blackSquare = Image.rectangle(30, 30) fillColor Color.black val redSquare = Image.rectangle(30, 30) fillColor Color.red val base = (redSquare beside blackSquare) above (blackSquare beside redSquare) count match { case 0 => base case n => val unit = chessboard(n-1) (unit beside unit) above (unit beside unit) } }
The solution could be just adding additional case on top:
case n if n<0 => Image.Empty
However, Dave suggested to turn it into a learning opportunity by adding:
I like his approach better.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
For example, calling chessboard(-1) will lead to endless recursion and eventually stack overflow.
The solution could be just adding additional case on top:
However, Dave suggested to turn it into a learning opportunity by adding:
I like his approach better.
The text was updated successfully, but these errors were encountered: