Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
spread operator function call ambiguity

When converting java StringTokenizer to kotlin split I'm unable to supply a list of character delimiters:

val delim : Array<Char> = arrayOf('(',')','{','}','[',/*many more...*/)
sourceExpr.split(delimiters=*delim,ignoreCase=false,limit=0)

Here kotlin compiler for some reason is unable to disambiguate between split(vararg String,...) and split(vararg Char,...). Questions:

  1. Is is a bug?
  2. Is there cast workaround?
  3. How did ancient pre-Collection era vararg concept infiltrated modern programming language?
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The issue isn't disambiguation but rather an incorrect type. In Kotlin, an Array<Char> is equivalent to a Java Character[]. That means that when you use *delim, you're actually creating a vararg Character (instead of vararg Char).

Instead, you should prefer the primitive-specific CharArray:

val delim: CharArray = charArrayOf('(', ')', '{', '}')
sourceExpr.split(delimiters = *delim, ignoreCase = false, limit = 0)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!