You always have to specify all the arguments for a constructor.
In Kotlin, you can omit specifying the values of constructor fields if they have default values:
class ConstructorWithDefaultArgumentsClass(
val param1: String,
val param2: Int = 300,
val param3: Boolean = false
)
fun constructorWithDefaultArgumentsExample() {
ConstructorWithDefaultArgumentsClass(param1 = "123")
}
After switching to Swift, this feature disappears, and all arguments must be specified when initializing an object:
ConstructorWithDefaultArgumentsClass(param1: "123", param2: 500, param3: false)