非専門家のSWIFT基礎文法-0


データ型

  • Int
  • UInt
  • Float
  • Double
  • Bool
  • Character
  • String
  • // Int
    var someInt: Int = -100
    someInt = 100
    
    // UInt(Unsigned Int)
    var someUInt: UInt = 200
    // someUInt = -200 // 음수 X
    
    // Float
    var someFloat: Float = 1.1
    someFloat = 1
    
    // Double
    var someDouble: Double = 1.1
    someDouble = 1
    
    // Bool
    var someBool: Bool = true
    someBool = false
    
    // Character
    var someCharacter: Character = "가"
    someCharacter = "A"
    someCharacter = "🐢"
    // someCharacter = "Hello, Swift!"  // String X
    
    // String
    var someString: String = "하이하이 🐢"
    
    // 타입 추론
    var number = 10