Skip to content

Instantly share code, notes, and snippets.

@mosser
Created March 28, 2016 08:01
Show Gist options
  • Save mosser/19c63397081553a0cb30 to your computer and use it in GitHub Desktop.
Save mosser/19c63397081553a0cb30 to your computer and use it in GitHub Desktop.
Object field initialization
trait Foo { def bar: String }
object PouetApp extends Foo with App {
override val bar = "geek"
}
PouetApp.bar
object Pouet extends Foo {
override val bar = "geek"
}
Pouet.bar
@mosser
Copy link
Author

mosser commented Mar 28, 2016

Execution in a Scala Worksheet:

defined trait Foo
defined module PouetApp
res0: String = null
defined module Pouet
res1: String = geek

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