Sobes.tech
Junior — Middle

Can you list the main data types used in Swift?

sobes.tech AI

Answer from AI

In Swift language, there are several basic data types used for storing information:

  • Int — integers (e.g., 42, -7).
  • Double — double-precision floating-point numbers (e.g., 3.1415).
  • Float — single-precision floating-point numbers.
  • Bool — boolean values (true or false).
  • String — text strings.
  • Character — a single character.
  • Optional — a type that can hold a value or nil.

Additionally, there are collections:

  • Array — an ordered list of elements of the same type.
  • Dictionary — a collection of key-value pairs.
  • Set — an unordered collection of unique elements.

Example of variable declarations:

let age: Int = 30
let pi: Double = 3.14
let isActive: Bool = true
let name: String = "Ivan"
let optionalValue: Int? = nil
Can you list the main data types used in Swift? — iOS - sobes.tech