Back to Intellij Community

ReplaceArrayOfWithLiteral

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/ReplaceArrayOfWithLiteral.html

2025.3-rc-2411 B
Original Source

Reports arrayOf calls that can be replaced with array literals [...].

Examples:

annotation class MyAnnotation(val strings: Array<String>)

  @MyAnnotation(arrayOf("alpha", "beta", "omega")) // replaceable 'arrayOf()'
  class MyClass

After the quick-fix is applied:

annotation class MyAnnotation(val strings: Array<String>)

  @MyAnnotation(["alpha", "beta", "omega"])
  class MyClass