본문 바로가기

Programming/Swift

Enumeration (열거형: list)

An enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code.

 

Enumeration Syntax

You introduce enumerations with the enum keyword and place their entire definition within a pair of braces:

enum SomeEnumeration {
    // enumeration definition goes here
}
Here’s an example for the four main points of a compass:

enum CompassPoint {
    case north
    case south
    case east
    case west
}

 

docs.swift.org/swift-book/LanguageGuide/Enumerations.html

 

'Programming > Swift' 카테고리의 다른 글

Properties and Methods  (0) 2020.10.13
Swift Optionals  (0) 2020.10.13
상수 constant  (0) 2020.10.13
Functions with Parameters  (0) 2020.10.12
Introduction to Functions  (0) 2020.10.12