Optional.orElseThrow

Gets the value of this optional if it exists, or throws an exception as produced by the given delegate.

  1. T orElseThrow(string msg)
  2. T orElseThrow(Exception delegate() exceptionSupplier)
    struct Optional(T)
    T
    orElseThrow
    (
    Exception delegate
    ()
    exceptionSupplier
    )

Parameters

exceptionSupplier Exception delegate
()

A delegate that returns an exception to throw if this optional is null.

Return Value

Type: T

The value of this optional.