applyIf<T> method

T applyIf<T>(
  1. bool? condition,
  2. T operation(
    1. T
    )
)

Apply the operation with T as parameter if condition is true

Implementation

T applyIf<T>(bool? condition, T Function(T) operation) {
  return (condition == true) ? operation(this as T) : this as T;
}