"jjj"
Swift Data Types
Swift Data Types (Types of Info You Can Use)
In Swift, every piece of data belongs to a type — this tells the system what kind of value it holds.
1. Int
Used for whole numbers like 5, 100, or -7.
let age: Int = 25
2. Double
Stores numbers with decimals. Great for precise values.
let pi: Double = 3.14
3. Float
Also stores decimal values but with slightly less precision.
let temperature: Float = 36.6
4. String
Holds a bunch of letters, words, or sentences.
let greeting: String = "Hello, Swift!"
5. Bool (Boolean)
Only true or false. Useful for decision-making.
let isSwiftFun: Bool = true
6. Array
Stores a list of items, like multiple numbers or names.
let fruits: [String] = ["Apple", "Banana", "Mango"]
7. Dictionary
Stores items as key-value pairs. Like a word and its meaning.
let student: [String: String] = ["name": "Alex", "grade": "A"]
8. Optional
Might have a value, or might be empty (nil).
var middleName: String? = nil
These types help Swift understand and handle your data correctly and safely.
Prefer Learning by Watching?
Watch these YouTube tutorials to understand GIT Tutorial visually:
What You'll Learn:
- 📌 Swift 4 Programming #2 - Variables and Data Types
- 📌 Swift Programming #1: Basic Data Types