Good afternoon, I'm new to Kotlin and working thro...
# getting-started
d
Good afternoon, I'm new to Kotlin and working through a Big Nerd Ranch book, I came across the function in their code and it isn't working, can someone help me with the solution. val healthStatus = when (healthpoints) { in 100..89 -> EXCELLENT_HEALTH in 90..99 -> GOOD_HEALTH in 75..98 -> MINOR_HEALTH in 75..89 -> if (isBlessed) {IS_BLESSED } else { } in 15..74 -> LOW_HEALTH else -> POOR_HEALTH } ... println("$name $healthStatus") isBlessed is set to true, and I have a string stored in const val IS_BLESSED. The issue I am having is that string is not printing regardless the range of the healthpoints.
Ok thanks for informing me, do you think you could answer the question?
c
Could you put some code that demonstrates the issue on https://try.kotlinlang.org/ ?
Oh wait - it looks like the MINOR_HEALTH range covers the IS_BLESSED range
t
Also I thought 100..89 doesn’t work? Doesn’t it have to be 89..100 or 100 downTo 89 (or w/e the operator was called?)