[swift-users] FloatingPoint equality ..

2017-06-29 Thread Gavin Eadie via swift-users
I've spent a fascinating evening and morning in the arcane depths of floating point, specifically researching the comparison of two floating point numbers. I pretty much understand how to do this with a combination of 'epsilon' and 'ULPs' after reading this

Re: [swift-users] FloatingPoint equality ..

2017-06-29 Thread Stephen Canon via swift-users
I should also point out: (a) your code can be somewhat simpler in Swift. I would probably write something along the lines of: func almostEqual(_ a: T, _ b: T) -> Bool { return a >= b.nextDown && a <= b.nextUp } (b) one ULP is almost never a tolerance you want to use. It’s much too small

Re: [swift-users] Decode a JSON object of unknown format into a Dictionary with Decodable in Swift 4

2017-06-29 Thread Itai Ferber via swift-users
Hi Kevin, > On Jun 29, 2017, at 12:30 PM, Kevin Wooten via swift-users > wrote: > >> Hi Jon, >> >> I just joined this mailing list and have tried to catch up on the >> history of this thread, so please excuse me if I’ve missed something. >> >> I’m sorry the Codable

[swift-users] New books

2017-06-29 Thread Bill Marcy via swift-users
Are there any books that you can recommend for Xcode 8.3.3 and Xcode 4.0? ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

[swift-users] Class vs Structures

2017-06-29 Thread Vitor Navarro via swift-users
Hi, I know this question is probably done a thousand times, but I wanted to hear from Swift dev community. I think both of them have right places for usage depending on the occasion but documentation, WWDC and the internet give opposite answers regarding this. Do you guys have any guideline

Re: [swift-users] Class vs Structures

2017-06-29 Thread Taylor Swift via swift-users
When in doubt, go with a struct. Probably nineteen types out of twenty I write are structs. Swift really is optimized with the assumption that you’re working with structs, that’s why almost everything in the standard library is a value type. Structs always pack contiguously into arrays, while

Re: [swift-users] Class vs Structures

2017-06-29 Thread Alex Blewitt via swift-users
> On 29 Jun 2017, at 18:16, Vitor Navarro via swift-users > wrote: > > Hi, > > I know this question is probably done a thousand times, but I wanted to hear > from Swift dev community. What is the question? > I think both of them have right places for usage depending

Re: [swift-users] Decode a JSON object of unknown format into a Dictionary with Decodable in Swift 4

2017-06-29 Thread Kevin Wooten via swift-users
> Hi Jon, > > I just joined this mailing list and have tried to catch up on the > history of this thread, so please excuse me if I’ve missed something. > > I’m sorry the Codable API at the moment does not answer your needs — > you’re clearly not the only one who’s run into this, so let’s see

Re: [swift-users] Class vs Structures

2017-06-29 Thread Vitor Navarro via swift-users
Hi Taylor, Thank you for the answer quite enlightening and also a better explanation than the short direction given by the docs. Could you please provide a sample for scoping with enums? I couldn't visualize it. Thanks again. 2017-06-29 14:41 GMT-04:00 Taylor Swift : >

[swift-users] swift 4 compiler error tuple parameter does not support destructing

2017-06-29 Thread CK TUNG via swift-users
I have the following code snippet that compile OK in swift 3             bytes = Array(UnsafeBufferPointer())             let filenamelength = bytes[(i+28)..<(i+28+2)]                 .enumerated()                 .map { (index, element) in return Int(Double(element) *

Re: [swift-users] Class vs Structures

2017-06-29 Thread Vitor Navarro via swift-users
Hi Alex, Thank you for the reply, actually Taylor gave me a great answer which solved my question, that was "struct or classes and when should we apply each". Regarding the reference I found this https://github.com/raywenderlich/swift-style-guide#code-organization which doesn't follow exactly

Re: [swift-users] swift 4 compiler error tuple parameter does not support destructing

2017-06-29 Thread Daniel Dunbar via swift-users
This is due to SE-0110: https://github.com/apple/swift-evolution/blob/master/proposals/0110-distingish-single-tuple-arg.md but see the additional commentary: https://lists.swift.org/pipermail/swift-evolution-announce/2017-June/000386.html For now you can rewrite it as: ``` let

Re: [swift-users] swift 4 compiler error tuple parameter does not support destructing

2017-06-29 Thread CK TUNG via swift-users
Many thanks.  It works in Swift 4 Xcode 9 beta2. On Jun 30, 2017, at 11:20 AM, Daniel Dunbar wrote: This is due to SE-0110:   https://github.com/apple/swift-evolution/blob/master/proposals/0110-distingish-single-tuple-arg.md but see the additional commentary:   

Re: [swift-users] FloatingPoint equality ..

2017-06-29 Thread Gavin Eadie via swift-users
.. agreed but this looks too awful (and is mostly a joke!) return a >= b.nextDown.nextDown.nextDown.nextDown && a <= b.nextUp. nextUp.nextUp.nextUp Thanks, friends, for your insights and info .. Gavin On Thu, Jun 29, 2017 at 3:30 PM, Taylor Swift via swift-users < swift-users@swift.org>

[swift-users] cascaded do/catch bug?

2017-06-29 Thread Marco S Hyman via swift-users
This macOS code in Xcode 8.3.3: if !fileManager.fileExists(atPath: (saveFileURL.path)) { do { 1 ==> try fileManager.linkItem(atPath: url.path, toPath: saveFileURL.path) 2 ==> } catch { // couldn't create hard link, copy file instead do { 3 ==>

Re: [swift-users] cascaded do/catch bug?

2017-06-29 Thread Jordan Rose via swift-users
That does sound like a bug to me. Can you make a self-contained test case and file at https://bugs.swift.org/ ? Thanks! Jordan > On Jun 29, 2017, at 14:00, Marco S Hyman via swift-users > wrote: > > This macOS code in Xcode 8.3.3: > >if

Re: [swift-users] cascaded do/catch bug?

2017-06-29 Thread Marco S Hyman via swift-users
> On Jun 29, 2017, at 4:20 PM, Jordan Rose wrote: > > That does sound like a bug to me. Can you make a self-contained test case and > file at https://bugs.swift.org/ ? Done. SR-5339 Marc ___ swift-users mailing list