Bool, Int, UInt, Float, Double, Character, String
int
로 인식하여 에러가 발생한다.var someBool: Bool = true
somBool = false
someBool = 0
someBool = 1
// error: cannot assign value of type 'Int' to type 'Bool'
var someInt: Int = -100
someInt = 100.1
// error: cannot assign value of type 'Double' to type 'Int'
var someUInt: UInt = 100
someUInt = -100
// error: negative integer '-100' overflows when stored into unsigned type 'UInt'
someUInt = someInt
// error: cannot assign value of type 'Int' to type 'UInt'
var someFloat: Float = 3.14
someFloat = 3
Float
은 받을 수 없다.var someDouble: Double = 3.14
someDouble = 3
someDouble = someFloat
// error: cannot assign value of type 'Float' to type 'Double'
var someCharacter: Character = "🍎"
someCharacter = "👍"
someCharacter = "가"
someCharacter = "A"
someCharacter = "안녕"
// error: cannot assign value of type 'String' to type 'Character'
+
연산자로 문자열을 합칠 수 있다.Character
타입을 받을 수 없다.var someString: String = "애플 🍎"
someString = someString + "Apple"
// 애플 🍎 Apple
someString = someCharacter
// error: cannot assign value of type 'Character' to type 'String'