Skip to content

Instantly share code, notes, and snippets.

@TakahashiIkki
Last active June 2, 2018 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TakahashiIkki/03ecddaa27c06b255e548c1a5e2e8fca to your computer and use it in GitHub Desktop.
Save TakahashiIkki/03ecddaa27c06b255e548c1a5e2e8fca to your computer and use it in GitHub Desktop.
// 列挙型のインスタンス化について
enum GenderEnum {
case man
case woman
case unisex
init?(type genderType: Int) {
switch genderType {
case 0:
self = .man
case 1:
self = .woman
case 2:
self = .unisex
default:
return nil
}
}
}
// インスタンス化の方法1
let man = GenderEnum.man
let woman = GenderEnum(type: 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment