cond<T, R> static method

R Function(T) cond<T, R>(
  1. List<(bool Function(T), R Function(T))> cases,
  2. R orElse(
    1. T
    )
)

Implementation

static R Function(T) cond<T, R>(
  List<(bool Function(T), R Function(T))> cases,
  R Function(T) orElse,
) {
  return (T input) {
    for (final caseEntry in cases) {
      if (caseEntry.$1(input)) {
        return caseEntry.$2(input);
      }
    }
    return orElse(input);
  };
}