Quick Answer
Functions that can be called without dot and parentheses
Understanding the Issue
Infix notation allows calling single-argument member functions or extension functions without the dot and parentheses, enabling more readable DSL-style code.
The Problem
This code demonstrates the issue:
Kotlin
Error
// Problem: Verbose function call
val result = myList.joinToString(separator = "|")
The Solution
Here's the corrected code:
Kotlin
Fixed
// Solution: Infix function
infix fun <T> List<T>.join(separator: String) =
this.joinToString(separator)
val result = myList join "|"
Key Takeaways
Use infix notation judiciously to create more readable APIs.