li'lfluf
10/31/2026, 3:43 PMinline fun <reified T : Enum<T>, V> ((T) -> V).find(value: V): T? {
return enumValues<T>().firstOrNull { this(it) == value }
}
enum class Animal(val string: String) {
Cat("cat"),
Dog("dog");
companion object {
// error: Return type 'Nothing' needs to be specified explicitly.
// error: Cannot use 'Nothing' as reified type parameter.
fun fromString(string: String) = Animal::string.find(string)
?: throw IllegalArgumentException("Bad animal: '$string'")
}
}
Any idea as to why, and why this behavior was changed? (Playground link)hho
10/31/2026, 5:11 PMYoussef Shoaib [MOD]
11/02/2026, 10:34 AMCLOVIS
11/02/2026, 12:54 PM