Skip to content

Instantly share code, notes, and snippets.

@jumbo-in-Jap
Last active September 12, 2017 09:27
Show Gist options
  • Save jumbo-in-Jap/0b92474c9da3f05355d4c1045eabc0e3 to your computer and use it in GitHub Desktop.
Save jumbo-in-Jap/0b92474c9da3f05355d4c1045eabc0e3 to your computer and use it in GitHub Desktop.
// Swiftと異なるポイント1. 複数の初期値の設定とアクセス
enum class Student(val firstName:String, val lastName:String, val age:Int){
STUDNET1(firstName = "tarou", lastName = "tanaka", age = 10),
STUDNET2(firstName = "jirou", lastName = "suzuki", age = 12)
}
print(Student.STUDNET1.firstName) // tarou
print(Student.STUDNET2.firstName) // jirou
print(Student.STUDNET1.toString()) // STUDNET1
// Swiftと異なるポイント2. 列挙型定数の利用によりfilterやforeachが使える
Student.values().forEach { student ->
print(student.firstName)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment