Skip to content

1.0.9

Compare
Choose a tag to compare
@skydoves skydoves released this 04 Dec 15:46
92ec158

🎉 Released a new version 1.0.9! 🎉

What's New?

  • Added WhatIfMap and deprecated whatIfLet.
    The basic concept is the same as whatIf. An expression for invoking whatIf when the target object is not null.
    It is useful when the receiver and the result should be different.
val length = nullableString.whatIfMap(
  whatIf = { it.length },
  whatIfNot = {
    log("$it, nullableString is null.")
    -1
  }
)
  • Added WhatIfAnd and WhatIfOr expressions for the nullable-Boolean iterables.
  • Added some expressions for collections.
    We can use default value instead of the whatIfNot and can be omitted the whatIfNot.
val length = nullableString.whatIfMap(
    default = -1
  ) { 
  log("$it, length can not over than 5.")
  5
}

We can use some expressions for List, Map, and Set.

  • whatIfNotNullOrEmpty: An expression for invoking whatIf when the List is not null and not empty.
  • addWhatIfNotNull: An expression for adding an element and invoking whatIf when the element is not null.
  • addAllWhatIfNotNull: An expression for adding an element and invoking whatIf when the element is not null.
  • removeWhatIfNotNull: An expression for removing an element and invoking whatIf when the element is not null.
  • removeAllWhatIfNotNull: An expression for removing a collection of element and invoking whatIf when the element is not null.