https://kotlinlang.org logo
c

christophsturm

03/11/2021, 11:18 AM
this seems to be better suited for here.
u

uli

03/11/2021, 11:31 AM
like in swift, where enum values are resolved against the infered type:
Copy code
let myEnum: MyEnum = .myEnumValue
c

christophsturm

03/11/2021, 11:37 AM
or in ruby
["abC","cdE"].map(&:downcase)
but thats more related to
listOf("aaa", "bbb").map(String::toLowerCase)
where
String
can also be infered.
e

elizarov

03/11/2021, 4:59 PM
In Kotlin
::id
is a reference to a top-level function named
id
without a receiver. For resolving against the inferred type there's a separate issue: KT-16768 Context-sensitive resolution (Resolve unqualified enum constants based on expected type)
u

uli

03/11/2021, 7:05 PM
You are certainly right
c

christophsturm

03/11/2021, 8:36 PM
it would be really great if there was a short form for methods or fields of a known class.
3 Views