0

I have a big list of strings. It contains about 100000 strings. These strings are relatively short: medium length is about 60 characters, the maximum length is about 300 characters. I want to hardcode this list in a source code of my application. I want to use listOf function:

val cities = listOf(
"Boston",
"Munich",
"Saint-Petersburg")

My code will be similar but listOf function will contain 100000 arguments. Is such code correct? Can Kotlin compiler compile correctly function call with 100000 arguments?

Andrey Epifantsev
  • 976
  • 1
  • 11
  • 27
  • 1
    About 64,000 max according to [this answer](https://stackoverflow.com/questions/18164255/what-is-the-maximum-of-number-of-arguments-for-varargs-in-java). – Robby Cornelissen Mar 05 '20 at 02:38
  • 2
    I don't know about this subject, but I suspect there are multiple different constraints you may violate with so many hard-coded strings, not just the limit on vararg length. – Tenfour04 Mar 05 '20 at 03:20

1 Answers1

1

I think you can have something about 64K arguments on a call. It is better you read this list with For-Loop from config file near your running file.