Menu

1 / 4

The story of one mother & two sons: value type vs reference type in Swift

We’ve moved to freeCodeCamp.org/news - Medium·Boudhayan Biswas·8 months ago
#v4Usqcox
Long article (1458 words) — no AI summary yet.
Reading 0:00
15s threshold

SwiftIOSProgrammingTechnologyMobile The story of one mother & two sons: value type vs reference type in Swift

Boudhayan Biswas

6 min readMay 21, 2019

--

Swift is a mother🤰and it has two sons 👬-

Value Type 🚴🏻♀️

Reference Type 🚴♂️

But what are their characteristics?🤼♂️

Do they behave the same or opposite to each other? 🧘♂️

Swift is a multi-paradigm programming language developed by Apple for iOS, macOS, watchOS, tvOS, Linux, and z/OS.💪

Just like other object-oriented programming languages, Swift has classes as building blocks which can define methods, properties, initializers, and can conform to protocols, support inheritance & polymorphism.👍

But, wait wait wait…🖐🖐🖐

Swift has structs also and it can define methods, properties, initializers and can conform to protocols with only one exception of inheritance.😳

What? Now I am confused!!! 🤔🤔🤔

Now let’s spice up your confusion: structs are not only the value types in Swift. Tuples and enums are also value types.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.