Skip to content

Instantly share code, notes, and snippets.

@j5ik2o
Created October 19, 2011 11:02
Show Gist options
  • Save j5ik2o/1297981 to your computer and use it in GitHub Desktop.
Save j5ik2o/1297981 to your computer and use it in GitHub Desktop.
Scala - オブジェクト(シングルトン)
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