https://kotlinlang.org logo
#getting-started
Title
# getting-started
k

Kaj Koivunen

02/10/2023, 10:25 AM
Does
next
hold some special meaning as a class member name? I'm curious because in IntelliJ code like
Copy code
class foo {
    var next: foo? = null
    var previous: foo? = null
    var prev: foo? = null
}
Generates unused warning for the class itself,
previous
and
prev
as expect but not for `next`(none of these are mentioned anywhere outside the class, of course). I.e. what is using the member
next
in my class and will I run into trouble down the road if I use that name?
Apparently it might be because
next
appears in iterator, since
hasNext
will also not generate unused, but I'm not exactly sure why this applies to a new class that has nothing to do with iterator
v

Vampire

02/10/2023, 12:10 PM
I'd assume it is a bug
m

mkrussel

02/10/2023, 1:14 PM
In general, I've found the unused inspection hit and miss. I'll often create a new class or add a new property/function with no warning.
2 Views