Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.

Commit f0f5394

Browse files
committed
制御してデフォルト引数を用いる
1 parent 64ebe5f commit f0f5394

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,3 +541,31 @@ data class Dst(
541541
val _bar: Int
542542
)
543543
```
544+
545+
### Other functions
546+
#### Control and use default arguments
547+
The `KMapper` uses the default argument if no argument is given.
548+
Also, if an argument is given, you can control whether to use it or not.
549+
550+
##### Always use the default arguments
551+
If you want to force a default argument, you can use the `KUseDefaultArgument` annotation.
552+
553+
```kotlin
554+
class Foo(
555+
...,
556+
@KUseDefaultArgument
557+
val description: String = ""
558+
)
559+
```
560+
561+
##### Use default argument if input is null
562+
The `KParameterRequireNonNull` annotation skips the input until a `non null` value is specified as an argument.
563+
By using this, the default argument is used when all the corresponding contents are `null`.
564+
565+
```kotlin
566+
class Foo(
567+
...,
568+
@KParameterRequireNonNull
569+
val description: String = ""
570+
)
571+
```

0 commit comments

Comments
 (0)