LocalDate::of - None of the following functions can be called with the arguments supplied

65 Views Asked by At

In kotlin, this works:

LocalDate.of(2023, 1, 1)

However when I try to use named parameters I get the error:

None of the following functions can be called with the arguments supplied:

public open fun of(p0: Int, p1: Month!, p2: Int): LocalDate! defined in java.time.LocalDate

public open fun of(p0: Int, p1: Int, p2: Int): LocalDate! defined in java.time.LocalDate

With either:

LocalDate.of(year=2023, month = Month.JANUARY, dayOfMonth=1)

or

LocalDate.of(year=2023, month = 1, dayOfMonth=1)
1

There are 1 best solutions below

0
k314159 On BEST ANSWER

Named parameters are only possible with Kotlin-defined functions.

As java.time.LocalDate is a Java class, you can't use named parameters.

See discussion.