Re: [swift-users] Class vs Structures

2017-06-30 Thread Taylor Swift via swift-users
An addendum: if something represents a specific “thing” that can’t be duplicated without consequence, often that means it should be stored in one specific place in your code, not made into a class. On Fri, Jun 30, 2017 at 10:10 PM, Brent Royal-Gordon via swift-users < swift-users@swift.org> wrote:

Re: [swift-users] Class vs Structures

2017-06-30 Thread Brent Royal-Gordon via swift-users
> On Jun 29, 2017, at 10:40 AM, Vitor Navarro via swift-users > wrote: > > Do you guys have any guideline regarding usage here? Here's my suggestion: Use a class when the object represents a specific *thing* that can't be duplicated without consequence; use a struct (or enum) when the instan

Re: [swift-users] Class vs Structures

2017-06-30 Thread Maury Markowitz via swift-users
> On Jun 29, 2017, at 2:42 PM, Taylor Swift via swift-users > wrote: > > When in doubt, go with a struct. Probably nineteen types out of twenty I > write are structs. The the 20th is likely when you're using one of Obj-C's features, like KVO. ___ s

Re: [swift-users] Class vs Structures

2017-06-29 Thread Taylor Swift via swift-users
The Ray Wenderlich style guide contains *some* useful insights, but you should not take it as a “swift best practices” guide, or even a good code style guide for your own projects. At the risk of sounding blunt, the RW style guide is optimized for blog posts and cheap tutorials, not a cohesive Swif

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 the

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 : > When in doubt, go with a

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 array

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 on the occasion > but do

[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 rega