Convert Pair constructor to 'to' function
Reports a Pair
constructor invocation that can be replaced with a to()
infix function call.
Explicit constructor invocations may add verbosity, especially if they are used multiple times. Replacing constructor calls with to()
makes code easier to read and maintain.
Example:
val countries = mapOf(
Pair("France", "Paris"),
Pair("Spain", "Madrid"),
Pair("Germany", "Berlin")
)
After the quick-fix is applied:
val countries = mapOf(
"France" to "Paris",
"Spain" to "Madrid",
"Germany" to "Berlin"
)
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Kotlin, @snapshot@ |
Last modified: 13 July 2023