Hi, is there a way to declare/force a platform typ...
# general-advice
e
Hi, is there a way to declare/force a platform type (
String!
) from Kotlin, with an annotation or similar? I'm making a regex helper where the result gets destructured, and i want the declared types specified for the named groups to decide nullability. for example:
Copy code
regex.match(string, "group", "nullable") { (groupString, nullableString: String?) -> ... }
Where
groupString
would be
String!
and
nullableString
would be
String?
, and an NPE would be thrown if
groupString
ends up being nullable when used. Right now, the only way I've managed to do this is by creating a helper function in java that returns the passed parameter without any nullability info. I would rather not rely on this method if there is a better way to do it, or is it not possible in pure Kotlin?
c
AFAIK it's not possible without having a Java method.