Documentation / dataflow / com.femastudios.dataflow.extensions / addIf
Go to reference

addIf

inline fun <T> MutableField<Collection<T>>.addIf(element: T, crossinline condition: (Collection<T>) -> Boolean): Boolean
inline fun <T> MutableField<List<T>>.addIf(element: T, crossinline condition: (List<T>) -> Boolean): Boolean
fun <T> MutableField<Set<T>>.addIf(element: T, condition: (Set<T>) -> Boolean): Boolean

Adds the given element to the collection if the condition is satisfied. The operation is atomic and thread-safe.

Return
true if the element has been added