ClampedPropertyWrapper Documentation Beta

Structure Clamped

@propertyWrapper
public struct Clamped<Value: Comparable> 

Initializers

init(wrapped​Value:​to:​)

public init(
        wrappedValue defaultValue: Value,
        to range: ClosedRange<Value>
    ) 

init(wrapped​Value:​to:​)

public init(
        wrappedValue defaultValue: Value,
        to range: Range<Value>
    ) 

Clamps a property to a "Half-Open" Range.

Example:

@Clamped(to: 1 ..< 1025)
var score: Int = 1024

Properties

wrapped​Value

public var wrappedValue: Value