Last active
September 12, 2017 09:27
-
-
Save jumbo-in-Jap/0b92474c9da3f05355d4c1045eabc0e3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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