Skip to content

Instantly share code, notes, and snippets.

@xfire
Created August 3, 2010 16:05
Show Gist options
  • Save xfire/506633 to your computer and use it in GitHub Desktop.
Save xfire/506633 to your computer and use it in GitHub Desktop.
class Foo(val a: Int, val b: String) {
private var _c: Int = 42 // fuer die meisten default
def c: Int = _c
def this(a: Int, b: String, c: Int) = {
this(a, b)
_c = c
}
}
val f1 = new Foo(33, "foo")
val f2 = new Foo(88, "bar", 23)
for(f <- List(f1, f2)) println("%d %s %d".format(f.a, f.b, f.c))
// -----------------------------------------
class Bar(val a: Int, val b: String, val c: Int = 42)
val b1 = new Bar(33, "foo")
val b2 = new Bar(88, "bar", 23)
for(f <- List(b1, b2)) println("%d %s %d".format(f.a, f.b, f.c))
// vim: set ts=2 sw=2 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment