Alternatively the Properties Behaviour syntax proposal could be applied to any 
declaration, assuming that it is accepted. 


> On 5 Jan 2016, at 4:18 AM, Amir Michail via swift-evolution 
> <[email protected]> wrote:
> 
> Examples:
> 
> invariant vectorIndex(v:Int) { return 0..<3 ~= v }
> 
> var i:Int,vectorIndex: = 2
> i = 3 // run-time error
> 
> invariant positive(v:Int) { return v > 0 }
> invariant odd(v:Int) { return v % 2 == 1 }
> 
> var x:Int, positive, odd = 5
> 
> x = 2 // run-time error
> 
> func f(z:Int, positive, odd) {
> …
> }
> 
> f(-3) // run-time error
> 
> 
> 
> 
> 
> 
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to