Created
June 25, 2014 15:30
-
-
Save willf/a1d9b939ccfc8f7d245b to your computer and use it in GitHub Desktop.
Simple Scala Student class
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
case class Student (fn: String, ln: String) { | |
def name() = s"$fn $ln" | |
def greet() = s"Hello, $name" | |
} | |
val s = Student("John", "Doe") | |
val l = List(s,s,s) | |
val res = l.map{_.name.length}.sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you could even omit the () in def name() to become def name = ...