Instance Property

unsafelyUnwrapped

The wrapped value of this instance, unwrapped without checking whether the instance is nil.

Declaration

var unsafelyUnwrapped: Wrapped { get }

Discussion

The unsafelyUnwrapped property provides the same value as the forced unwrap operator (postfix !). However, in optimized builds (-O), no check is performed to ensure that the current instance actually has a value. Accessing this property in the case of a nil value is a serious programming error and could lead to undefined behavior or a runtime error.

In debug builds (-Onone), the unsafelyUnwrapped property has the same behavior as using the postfix ! operator and triggers a runtime error if the instance is nil.

The unsafelyUnwrapped property is recommended over calling the unsafeBitCast(_:) function because the property is more restrictive and because accessing the property still performs checking in debug builds.

See Also

Inspecting an Optional

func hash(into: inout Hasher)

Hashes the essential components of this value by feeding them into the given hasher.

var debugDescription: String

A textual representation of this instance, suitable for debugging.

var customMirror: Mirror

The custom mirror for this instance.