0

In Scala language, of what maximum size that a developer can define for

  • Tuple
  • Array
  • List

Thanks

ira wati
  • 89
  • 1
  • 10
  • 1
    You should at least take some effort to specify precisely what you mean by *"define length"*. What exactly do you mean by "length"? The `Int` value returned by the `.size` method on `Array` and `List`? That would be different than the `Long` length that you theoretically could obtain on a computer with a stupidly gigantic amount of memory that can hold more than 2^31-1 list elements. – Andrey Tyukin Jul 03 '18 at 16:17
  • @Andrey, Here is an example of what I meant, like array[10]. Meaning the array is of size 10. Having established what I meant above, I have updated the title and body with size. Hope this have eradicated the confusion. – ira wati Jul 03 '18 at 16:28

1 Answers1

5

Tuple: 22 (see Why are scala functions limited to 22 parameters?)

List: Practically speaking, since various list length methods return Int, it's effectively Int.MaxValue

Array: Same as List, but as Andrey points out in the comments, you cannot ask for more than Int entries

joel
  • 6,359
  • 2
  • 30
  • 55
  • Arrays are also limited by the simple fact that you cannot ask for more than `Int` entries anyway... It's more 32-bit backwards-compatibility issue rather than memory issue. – Andrey Tyukin Jul 03 '18 at 16:19