struct | class |
Value type | Reference type |
Cannot inherit or be inherited | Has inheritance |
On the Stack | On the heap |
Faster | Slower |
No memory leaks | Potential memory leaks |
Deep copies | |
True immutability | |
Threadsafe | |
Works with Objective-C code |
Use struct as much as possible.
I guess Swift learns this from C#.
Java doesn’t have struct keyword.