Last active
June 2, 2018 08:27
-
-
Save TakahashiIkki/03ecddaa27c06b255e548c1a5e2e8fca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 列挙型のインスタンス化について | |
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