Skip to content

Commit c6102bd

Browse files
committed
Release version 1.0.3
1 parent cda576a commit c6102bd

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Add a dependency code to your **module**'s `build.gradle` file.
2323
```gradle
2424
dependencies {
25-
implementation "com.github.skydoves:whatif:1.0.2"
25+
implementation "com.github.skydoves:whatif:1.0.3"
2626
}
2727
```
2828

@@ -92,24 +92,32 @@ nullableObject.whatIfNotNull(
9292
```
9393

9494
### WhatIfNotNullOrEmpty
95-
An expression for invoking `whatIf` lambda when the __collections__ or __array type__ is not null and not empty.<br>
95+
An expression for invoking `whatIf` lambda when the __string__, __collections__ and __array type__ is not null and not empty.<br>
9696
If the collections or array type target is null or empty, `whatIfNot` will be invoked instead of the `whatIf`.
97+
98+
```kotlin
99+
val nullableString: String? = "NotNullOrEmpty"
100+
nullableString.whatIfNotNullOrEmpty {
101+
log("$it is not null or empty")
102+
}
103+
```
104+
Here is an example for collections.
97105
```kotlin
98106
nullableList.whatIfNotNullOrEmpty {
99-
log("list is not null and not empty : $it")
107+
log("list $it is not null and not empty")
100108
}
101109
```
102110
And we can handle the null or empty case.
103111
```kotlin
104112
nullableList.whatIfNotNullOrEmpty(
105-
whatIf = { log("list is not null and not empty : $it") },
113+
whatIf = { log("list $it is not null and not empty") },
106114
whatIfNot = { log("list is null or empty") }
107115
)
108116
```
109117
Here is the same example for the array.
110118
```kotlin
111119
nullableArray.whatIfNotNullOrEmpty {
112-
log("array is not null and not empty")
120+
log("$it is not null and not empty")
113121
}
114122
```
115123
#### Array

dependencies.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ ext.versions = [
22
minSdkLib : 15,
33
minSdkDemo : 16,
44
compileSdk : 29,
5-
versionCode : 3,
6-
versionName : '1.0.2',
5+
versionCode : 4,
6+
versionName : '1.0.3',
77

88
gradleBuildTool : '3.5.0',
99
spotlessGradle : '3.24.2',

0 commit comments

Comments
 (0)