3 ms·
In Swift this brought a specific reward, or did, but it's been a few years since I was hardcore writing Swift so forgive me if my memory is a bit off or perhaps
by rubyn00bie 6y ago
In Swift this brought a specific reward, or did, but it's been a few years since I was hardcore writing Swift so forgive me if my memory is a bit off or perhaps I didn't fully understand it but...
When I was writing a lot of Swfit this approach was substantially more banger than just being an interface, but it had a caveat-- your structs needed to be less than like four members (maybe three?) and if so Swift would just use the stack without having to do a bunch of heap allocations like with a class (or even a large struct). That is to say, the compiler and runtime had a trick this sort of pattern unlocked. I'd even guess now there's something extra going on under-the-hood by the Siwft compiler to make this style of programming moar gooder... but I'm super out of date with my Swift knowledge.