Created
March 26, 2016 13:49
-
-
Save shigemk2/ade7752d2a7de8d40c18 to your computer and use it in GitHub Desktop.
forのサンプル
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
case class Student(name: String, age: Int, grade: Int) | |
val list = List( | |
Student("Steve", 15, 1), | |
Student("Chad", 16, 2), | |
Student("Shigeru", 40, 1), | |
Student("Chloé", 18, 3) | |
) | |
val students = for { | |
student <- list | |
name <- student.name | |
} yield name | |
println(students) | |
val studentNames = for { | |
student <- list | |
} yield student.name | |
println(studentNames) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment