If `when (a) in x..y` is deprecated, what should I use instead?

Viewed 94

So im trying to do a when statement for when a is in a certain degree of 360, this is the method I'm currently using:

var a: Double = 0.0

...

primaryDirection = when (a) {
    in 45..135 -> Direction.RIGHT
    in 135..225 -> Direction.DOWN
    in 225..315 -> Direction.LEFT
    else -> Direction.UP
}

However each of the in keywords is saying that it's deprecated... So what should I replace this with?

1 Answers

Oh I just figured it out... Its because 'a' was a Double and the range was an Int range, changing a to be an int fixed the warning.

Image of the warning explains it better

Related