ios – “Sort of expression is ambiguous with out extra context” – Property Wrapper in Swift and XCode 14

[ad_1]

I am getting an error with the next code in Swift. The code is okay if I don’t use a property wrapper. I get Sort of expression is ambiguous with out extra context in XCode 14.

@propertyWrapper
public struct Clamping<Worth: Comparable> {
    var worth: Worth
    let vary: ClosedRange<Worth>
    

    public init(wrappedValue worth: Worth, _ vary: ClosedRange<Worth>) {
        self.worth = min(max(vary.lowerBound, worth), vary.upperBound)
        self.vary = vary
    }

    public var wrappedValue: Worth {
        get { worth }
        set { worth = min(max(vary.lowerBound, newValue), vary.upperBound) }
    }
}

var dragGesture: some Gesture {
    DragGesture()
        .onChanged { worth in
            @Clamping(0...1) var progress: CGFloat = (120 + worth.translation.width) / 120
            updateSampleView(progress: progress)
        }
    
}

[ad_2]

Leave a Reply