Reputation: 8580
val a = 2
if (a==1 | a==2) {
}
This code doesnt compile - error "Unexpected tokens (use ; to separate expressions in the same line)
How to solve? why is that even a problem? and why do the tutorials not aware of that compilation error here ?
Kotlin playground with that code
Upvotes: 0
Views: 1106
Reputation: 1261
looks like a mistake on translating it to kotlin. if you look on the java part they use
if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER ||
geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT)
so in that case use or keyword or ;-) ||
fun main() {
println("Hello, world!!!")
val a = 2
if ((a==1) or (a==2)) {
println("fine")
}
}
Upvotes: 1