&引用;在;Android Studio Kotlin中的代码无法识别

&引用;在;Android Studio Kotlin中的代码无法识别,kotlin,Kotlin,我复制粘贴了教程中的一些代码,但当我来到这里时: azimuth = Math.round(azimuth.toFloat()) compass_image.rotation = (-azimuth).toFloat() val where = when(azimuth){ in 281...348 -> "NW" in 281...348 -> "NW" in 281...348 -> "NW"

我复制粘贴了教程中的一些代码,但当我来到这里时:

azimuth = Math.round(azimuth.toFloat())
    compass_image.rotation = (-azimuth).toFloat()

    val where = when(azimuth){
        in 281...348 -> "NW"
        in 281...348 -> "NW"
        in 281...348 -> "NW"
        in 281...348 -> "NW"
        in 281...348 -> "NW"
        in 281...348 -> "NW"
        in 281...348 -> "NW"
        else -> "N"
    }

    view_degree.text = "$azimuth° $where"
Android Studio无法识别“in”命令。。。怎么会?
提前感谢

这是因为你必须用两点而不是三点来表示范围。此外,所有这些情况都是相同的,所以重复它们是没有用的

val where=when(方位角){
在281..348->“西北”
else->“N”
}

此处的附加信息:

在@MichielLeegwater中的附加信息谢谢,我已将其添加到答案中。