This does not work:
def giveArray[T](elem:T):Array[T] = { new Array[T](1) }
But it does:
def giveList[T](elem:T):List[T] = { List.empty[T] }
I'm sure this is a pretty simple thing, and I know that arrays can behave a bit unusual in Scala.
Can someone explain to me how to create such an array and why it doesn't work in the first place?
arrays scala
Plankalkรผl
source share