samedi 6 mai 2017

Kotlin check if function requires instance parameter

If a KCallable is created using Any()::toString then when it's later referenced you don't need to pass that Any instance (when using call). Though if it's created using Any::toString (not an instance of Any) it's required to pass a Any instance.

My question is can I easily find out whether I need to pass that instance parameter? I found a way to do this: callable.parameters[0].kind == KParameter.Kind.INSTANCE but it isn't quite nice and I wonder if there's an easier or recommended way to do this. Thanks!





Aucun commentaire:

Enregistrer un commentaire