Variables

#variables

Overview

Whenever possible, always prefer constants over variables. In this way, Apple will stop you from an error.

Variables

  • int = 1

  • double = 3.14

  • string = "Hello"

  • bool = True / False

Sample parts of the code

var greeting = "Hello, playground"
  • var => type

  • greeting => variable name

  • = => assign

  • "" => variable value. Since it has " marks on both sides, it is String

private var & private (set)

To give access to outside of the struct you should initialize it (init).

Even if one of the properties is private and did not call from outside of the struct, you should initialize it.

Videos

Hacking With Swift / 100 days / 11 - How to limit access to internal data using access control

Sources

Sources

Videos

Articles / Documents

Last updated

Was this helpful?