If.block constructor

If.block(
  1. List<Iff> iffs
)

Checks the conditions for iffs in order and executes the first one whose condition is enabled.

Implementation

If.block(this.iffs) {
  for (final iff in iffs) {
    if (iff is Else) {
      if (iff != iffs.last) {
        throw InvalidConditionalException(
            'Else must come last in an IfBlock.');
      }

      if (iff == iffs.first) {
        throw InvalidConditionalException(
            'Else cannot be the first in an IfBlock.');
      }
    }
  }
}