Function able to accept super type?

Viewed 12

I have this scala3 code:

val times4 = List.fill(4)
val oranges = times4("orange")
println(oranges)

Output is:

List(orange, orange, orange, orange)

But, is this correct behaviour? Because intellij tells me times4 is:

Nothing => List[Nothing]

But it is able to accept String type, while String is not a Nothing

0 Answers
Related