optionalWith method

  1. @useResult
Parser<R> optionalWith(
  1. R value
)

Returns new parser that accepts the receiver, if possible. The resulting parser returns the result of the receiver, or value if not applicable.

For example, the parser letter().optionalWith('!') accepts a letter as input and returns that letter. When given something else the parser succeeds as well, does not consume anything and returns '!'.

Implementation

@useResult
Parser<R> optionalWith(R value) => OptionalParser<R>(this, value);