Optional

annotation class Optional

Don't send a parameter if it is null (if nullable) or default (if ServerDefault). Must be used on a nullable parameter or a parameter of type ServerDefault.

If a nullable @Optional parameter is not present in a call to the server, null will be used, not any default.

Nullable @Optional parameters will have their defaults evaluated at the call side, and only not passed to the server if they are null.

ServerDefault@Optional parameters must have a default value, and won't be passed to the server if their value is not specified (i.e. the default is used). In that case, the default will be evaluated on the server.

If you want to use a default value when the parameter is not specified, make the parameter default to null and use ?: in the server method body, or use ServerDefault.

Optional parameters may be used in optional blocks in an endpoint (see KrosstalkEndpoint).

Constructors

Link copied to clipboard
fun Optional()

Sources

Link copied to clipboard