Skip to content

Instantly share code, notes, and snippets.

@nbness2
Created November 27, 2021 11:25
Show Gist options
  • Save nbness2/d2c4523a5f05a54fc7be405ef999181c to your computer and use it in GitHub Desktop.
Save nbness2/d2c4523a5f05a54fc7be405ef999181c to your computer and use it in GitHub Desktop.
val random = Random
val randomNumber = random.nextInt()
val positiveInts = 1 .. Int.MAX_VALUE
val negativeInts = -1 downTo Int.MIN_VALUE
val sign = when(randomNumber) {
in positiveInts -> "positive"
in negativeInts -> "negative"
else -> "zero"
}
println("Number is $sign")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment