Operator == cannot be applied to ‘Long’ and ‘Int’ in Kotlin

Simply use long on your right side

if (drawerItem.identifier == 1L)

Edit: the reason this is required is that Kotlin does not promote Ints to Longs (or, more generally, does not widen types); on the left side we had a Long and on the right side we had an Int, which lead to the error. Explicitly indicating that the right side is a Long fixes the error.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)