Hi, In an Android project, I want to make two meth...
# language-proposals
l
Hi, In an Android project, I want to make two methods that return a delegate, with one allowing nullable values, and the other not. It's for Fragment arguments. The idiomatic way would be to add 2MB to my app by using kotlin-reflect to check if the delegated property is nullable. Instead, I aim for the lightweight way, which makes me write two delegates, one for nullable values, another for non nullables. I wrote two functions
arg()
and
'arg?'()
(the single quotes being backticks, just Slack limitation), but the IDE says
?
is not allowed in identifiers in Android projects. So I added the
JvmName("argOfNullable")
, but the IDE still complains, and I assume the compiler will too. So, please, could you add the ability to apply the identifier restriction only on the JVM name in the nearest Kotlin release possible?
d
Isn't
argOrNull()
more explicit? The ? In the middle of a function name might be very confusing...
l
@dave08
argOrNull()
is a great naming suggestion, will use it, thanks! My proposal still applies to other use cases though, because we would love to use emoji named functions in Android projects for more Kotlin fun! Especially since they just fixed the 🍔 emoji!
1
🍔 2