thana
01/29/2019, 7:17 AMnatpryce
01/29/2019, 8:19 AMas?
operator so that the type is inferred by the compiler and the caller does not have to pass in a class instance.thana
01/29/2019, 8:25 AMreified
only works for ionline functions. how can i build a map this way?natpryce
01/29/2019, 8:30 AMclass Example {
fun store = mutableMapOf<String, Any>()
operator fun set(key: String, value: Any) {
store[key] = value
}
inline operator fun <reified T:Any> get(key:String): T? =
store[key] as? T
}
natpryce
01/29/2019, 8:33 AMnatpryce
01/29/2019, 8:37 AMnatpryce
01/29/2019, 8:37 AMthana
01/29/2019, 8:41 AMthana
01/29/2019, 8:43 AM