Skip to content

Instantly share code, notes, and snippets.

@wfaler
Created September 19, 2014 15:27
Show Gist options
  • Save wfaler/7dc5e34695c1f7eb10d9 to your computer and use it in GitHub Desktop.
Save wfaler/7dc5e34695c1f7eb10d9 to your computer and use it in GitHub Desktop.
WTF-SCALA.scala
class Foo{
val foo = List(bar)
val bar = baz
val baz = "foo"
}
// compiles
@viktorklang
Copy link

scala> class Foo{
| val foo = List(bar)
| val bar = baz
| val baz = "foo"
| }
:9: warning: Reference to uninitialized value bar
val foo = List(bar)
^
:10: warning: Reference to uninitialized value baz
val bar = baz
^
defined class Foo

@Sciss
Copy link

Sciss commented Sep 19, 2014

I think this should be clearly an error not a warning. Any reason to allow it? @viktorklang

@teigen
Copy link

teigen commented Sep 19, 2014

scala> val troll = new { override val bar = "oh-really" } with Foo
troll: Foo = $anon$1@2f4854d6

scala> troll.foo
res13: List[String] = List(oh-really)

scala> troll.bar
res14: String = oh-really

scala> troll.baz
res15: String = foo

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