https://kotlinlang.org logo
Title
d

dumptruckman

07/08/2017, 4:03 AM
If I'm trying to Kotlinize and add some convenience to this Java API where there's `Thing SomeSingleton.getThing(String)`(a lookup method which may return null), what would be the most idiomatic way to add this to CharSequence?
fun CharSequence.getThing(): Thing?
or
val CharSequence.thing: Thing?
feels wrong because it makes seem like the Thing belongs to the CharSequence.
fun CharSequence.toThing(): Thing?
feels wrong because it seems like this should throw an exception if the Thing is not found I'm not really sure what's left. Thoughts?
d

dumptruckman

07/08/2017, 1:12 PM
Oh, nice. Thanks