Skip to content

Instantly share code, notes, and snippets.

@willf
Created June 25, 2014 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willf/a1d9b939ccfc8f7d245b to your computer and use it in GitHub Desktop.
Save willf/a1d9b939ccfc8f7d245b to your computer and use it in GitHub Desktop.
Simple Scala Student class
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
@razie
Copy link

razie commented Jun 25, 2014

you could even omit the () in def name() to become def name = ...

@v6ak
Copy link

v6ak commented Jul 21, 2014

I would write Seq instead of List.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment