operator + method

  1. @override
Instruction<MemoryCell<T>, Pulse, Pulse> operator +(
  1. covariant Instruction<Cell, Pulse, Pulse> other
)
override

Combines this instruction with another to create an InstructionChain.

When to use

This is the most idiomatic and readable way to compose multiple instructions. Use it to fluently build a sequential processing pipeline without the verbosity of the Instruction.chain factory.

How it works

  1. It creates an InstructionChain where this instruction is executed first.
  2. The output of this is passed as the input to the other instruction.
  3. The resulting chain is itself an Instruction, allowing for continuous, multi-stage composition.

Parameters:

  • other: The instruction to append to the processing chain.

Returns:

A new InstructionChain containing both instructions.

Example

final pipeline = trim + validate + persist;

Implementation

@override
Instruction<MemoryCell<T>, Pulse, Pulse> operator +(
        covariant Instruction other) =>
    _body + other;