Basic types and strings in Swift
Compare numeric and Boolean types, then explore characters, strings, and Unicode-aware access.
Read the Korean original on Velog ↗English translation

A type describes what a value means and which operations it supports. Swift infers many types, but explicit annotations can clarify intent or specify the precision required.
Numeric and Boolean types
Int: signed integers, including negative values, zero, and positive values.UInt: unsigned integers, including zero and positive values.Float: 32-bit floating-point numbers.Double: 64-bit floating-point numbers.Bool:trueorfalse.
let count: Int = -100
let progress: Double = 0.75
let isFinished: Bool = false
Character and String
A Character represents an extended grapheme cluster, and a String is a collection of characters.
let symbol: Character = "🙂"
var greeting = "Hi"
greeting.append(", there!")
let name = "snack"
let introduction = "안녕하세요, \(name)입니다."
introduction.hasPrefix("안녕") // true
Swift strings account for Unicode character boundaries, so they use String.Index rather than integer offsets for indexing. Write single-line comments with // and block comments with /* ... */. Comments are especially useful for explaining why a choice was made.