Created
November 27, 2021 11:29
-
-
Save nbness2/826bf6bd3e0d5fc993f71a4110841929 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val random = Random | |
val positiveInts = 1 .. Int.MAX_VALUE | |
val negativeInts = -1 downTo Int.MIN_VALUE | |
val sign = when(val randomNumber = random.nextInt()) { | |
in positiveInts -> "positive $randomNumber" | |
in negativeInts -> "negative $randomNumber" | |
else -> "zero" | |
} | |
println("Number is $sign") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment