I don’t know about the candidates
But the uptimeNanoseconds is a UInt64 and as such you should probably use
substractWithOverflow.
var a: UInt64 = 12
var b: UInt64 = 25
let result = UInt64.subtractWithOverflow(a, b)
if result.overflow {
print("Overflow")
} else {
let answer = result.0
}
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl
> On 16 Feb 2017, at 16:56, J.E. Schotsman via swift-users
> <[email protected]> wrote:
>
> Hello,
>
> I am trying to define an operator that subtracts dispatch times:
>
> #import Dispatch
>
> func -( time1: DispatchTime, time2: DispatchTime ) -> DispatchTimeInterval
> {
> return DispatchTimeInterval.nanoseconds( time2.uptimeNanoseconds -
> time1.uptimeNanoseconds )
> }
>
> Compiler says: Ambiguous use of operator ‘-'
> Found this candidate
> Found this candidate
>
> As usual the candidates are unknown.
>
> What am I doing wrong?
>
> Jan E.
> _______________________________________________
> swift-users mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-users
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users