`is` prefix for Boolean returning methods is quite...
# announcements
i
is
prefix for Boolean returning methods is quite straight forward. I wonder what are you thoughts on adding
is
prefix to Boolean properties?
Copy code
// method
view.isVisible()

// property
view.visible
or
view.isVisible
k
In this case I lean towards
visible
but it's an internal struggle every time simple smile
d
I think at this point Kotlin has been in production too long to make that change, even if I would like to see it (I'm not a huge fan of property syntax in general, so I'm probably biased).
s
I personally prefer
view.isVisible
, but it depends on whether you need the accessors to be used (by java code or some lib like jackson)
Copy code
// kotlin
class Foo(val cool:Boolean,val isHot:Boolean)

// java
public class Java {
    public static void main(String[] args) {
        Foo foo = new Foo(true, true);
        foo.getCool(); // not very cool :(
        foo.isHot();
    }
}
you could add
@getter:JvmName("isCool")
to the property, but this is uglier than in the first place ^^
k
@dalexander what change?
d
I was just thinking about how properties can be exposed which may not follow boolean naming conventions?
But it's slightly off topic from the original question I suppose. I do lean towards
isFoo
pretty heavily.
a
I write
isVisible: Boolean
rather than
visible: Boolean
Because of java interop, but also like I would write
hasChildren: Boolean
and not
children: Boolean
Also, there’s #codingconventions 😉
👍 1
i
Let’s assume Java is not there - pure Kotlin project
a
For example
view.takeIf { it.isVisible }
reads better than
view.takeIf { it.visible }