Published: 25 Jan 2019 › Updated: 25 Jan 2019![[Grammer] 11 - Type Inference, Type Safety, 12 - Type Conversion, Type Aliases](/nhc-explorer-cover.webp)
![[Grammer] 11 - Type Inference, Type Safety, 12 - Type Conversion, Type Aliases](/nhc-explorer-cover.webp)
[Grammer] 11 - Type Inference, Type Safety, 12 - Type Conversion, Type Aliases
- Type Inference: 타입을 값을 보고 추론함.
let num = 123
- Type Annotation : 타입을 직접 지정함
let num: Int = 123
Type Safety : 안정성을 위해 자료형을 엄격히 구분. 모든 타입간 호환 불가.
Int+Double / Int8+Int 등 모두 에러. 이러한 계산은 형변환이 필요.Type Conversion : Type(value)
let a = 123
let b = 4.56
let result1 = Double(a) + b // 127.56
let result2 = a + Int(b) // 127
- Type Aliases : typealias NewName = TypeName
typealias Coordinate = Double
let lat: Double = 37.497942
let lon: Coordinate = 127.027621Leave [Grammer] 11 - Type Inference, Type Safety, 12 - Type Conversion, Type Aliases to:
Read more #swift4 posts
Best Posts From gunw
We have not curated any of gunw's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From gunw
- [Grammer] 26 - Custom Operators
- [Grammer] 25 - Operator Methods
- [Grammer] 23 - Bitwise Operators, 24 - Identity Operator
- [Grammer]21 - Ternary Coditional Operator, 22 - Range Operators
- [Grammer] 19 - Short-circuit Evaluation, Side Effect, 20 - Assignment Operators
- [Grammer] 16 - Overflow Operators, 17 - Comparison Operators, 18 - Logical Operators
- [Grammer] 13 - Data Types with Memory, 14 - Operator Basics, 15 - Arithmetic Operators
- [Grammer] 11 - Type Inference, Type Safety, 12 - Type Conversion, Type Aliases
- [Grammer] 09 - Boolean, 10 - Strings and Characters
- [Grammer] 07 - Naming Convention, 08 - Numbers