Created
October 19, 2011 11:02
-
-
Save j5ik2o/1297981 to your computer and use it in GitHub Desktop.
Scala - オブジェクト(シングルトン)
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
class Employee(val name:String) | |
object EmployeeTable { | |
def insert(employee:Employee):Unit = { /* DBに保存 */ } | |
def selectAll:List[Employee] = { /* DBから検索 */ } | |
} | |
// EmployeeTableがインスタンスそのもので、クラスは見えないところにある。 | |
EmployeeTable.insert(new Employee("Junichi Kato")) | |
val employees = EmployeeTable.selectAll | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment