https://kotlinlang.org logo
#announcements
Title
# announcements
m

marcinmoskala

10/05/2019, 4:19 PM
A question about nomenclature. Is is fair to say that generic functions are made by type parameter before those functions. The objection is that methods in generic classes are also generic functions so they can also be made by type parameter before hosting class. Is it so? Would you call such methods generic functions or rather methods in generic classes?
k

karelpeeters

10/05/2019, 7:15 PM
I would not call functions that don't introduce extra generic types "generic", but it's kind of fuzzy.
w

wasyl

10/05/2019, 7:25 PM
Not directly Kotlin, but Java’s specification says that
A method is generic if it declares one or more type variables.
(https://docs.oracle.com/javase/specs/jls/se13/html/jls-8.html#jls-8.4.4). Nothing is said about enclosing class or interface, so I’d go for the option that generic function are the ones that have an explicit type parameter.
👍 1
m

marcinmoskala

10/05/2019, 9:06 PM
Thanks, great 🙂
3 Views