48 Generic functions
first<T> returns the same type as its two arguments. Explicit type arguments here show two instantiations of one function.
norm
T first<T>(T left, T right) {
return left
}
main() {
Integer number = first<Integer>(left: 7, right: 9)
String label = first<String>(left: "Norm", right: "Java")
printLine(number)
printLine(label)
}Expected output:
text
7
NormTry it: Try passing an Integer and a String in one call.
Precise rules: Reference.