Re: [swift-users] ambiguous minus operator

2017-02-17 Thread J.E. Schotsman via swift-users
> On 16 Feb 2017, at 18:58, Saagar Jha wrote: > > DispatchTimeInterval.nanoseconds expects an Int, while uptimeNanoseconds is > an UInt64 (an thus so is their difference). You can “fix” this by adding an > explicit cast: Aha! So this was just a confusing compiler

Re: [swift-users] ambiguous minus operator

2017-02-16 Thread Zhao Xin via swift-users
I don't know if you are using an IDE, but in Xcode. I can just cmd+mouse left click to see the code headers. Zhaoxin On Fri, Feb 17, 2017 at 2:22 AM, Jon Shier via swift-users < swift-users@swift.org> wrote: > I’ve had good luck with being able to click the candidates in > cases like

Re: [swift-users] ambiguous minus operator

2017-02-16 Thread Jon Shier via swift-users
I’ve had good luck with being able to click the candidates in cases like this so Xcode will navigate to those bits of code. However, in this case I think the issue is that the candidates weren’t from user code but from the standard library, which Xcode has all sorts of issues navigating

Re: [swift-users] ambiguous minus operator

2017-02-16 Thread Jordan Rose via swift-users
> As usual the candidates are unknown. Just on this particular note, this is a terrible presentation issue and totally something we Apple people need to fix in Xcode, but you can usually see what the candidates were in the build log. Jordan > On Feb 16, 2017, at 07:56, J.E. Schotsman via

Re: [swift-users] ambiguous minus operator

2017-02-16 Thread Saagar Jha via swift-users
DispatchTimeInterval.nanoseconds expects an Int, while uptimeNanoseconds is an UInt64 (an thus so is their difference). You can “fix” this by adding an explicit cast: func -(time1: DispatchTime, time2: DispatchTime) -> DispatchTimeInterval { return

Re: [swift-users] ambiguous minus operator

2017-02-16 Thread Rien via swift-users
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

[swift-users] ambiguous minus operator

2017-02-16 Thread J.E. Schotsman via swift-users
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