https://kotlinlang.org logo
Title
m

menegatti

01/23/2018, 1:00 PM
what’s the error message if you don’t change to
Any
?
b

bruno.gsantos89

01/23/2018, 1:01 PM
That i need to specify the type, but i want a generic like in java, for example only Validator type without passing type, is it possible?
A simple example could be, a fun that receives a generic Comparator with param: fun generic(comparator: Comparator)
m

menegatti

01/23/2018, 1:04 PM
you need to update
validateForm
to
fun <T> validateForm(validator: Validator<T>) {}
b

bruno.gsantos89

01/23/2018, 1:06 PM
Alright nice, in java form is not possible alright? Without pass arg type?
m

menegatti

01/23/2018, 1:07 PM
not sure, I guess not
b

bruno.gsantos89

01/23/2018, 1:12 PM
ok thank you!!!
e

etibaldi

01/23/2018, 1:50 PM
even though type erasure is still a thing at runtime (because of the JVM), Kotlin explicitely forbids erasing type at compile time to avoid ambiguities.
b

bruno.gsantos89

01/23/2018, 3:42 PM
Nice explanation, thank you