Created
February 17, 2013 21:59
-
-
Save milessabin/4973733 to your computer and use it in GitHub Desktop.
Lazy pattern matching in Scala.
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
Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_05). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> def foo = { println("foo"); "foo" } | |
foo: String | |
scala> def bar = { println("bar"); "bar" } | |
bar: String | |
scala> def baz = { println("baz"); "baz" } | |
baz: String | |
scala> lazy val List(a, b, c) = List(foo, bar, baz) | |
a: String = <lazy> | |
b: String = <lazy> | |
c: String = <lazy> | |
scala> a | |
foo | |
bar | |
baz | |
res0: String = foo | |
scala> b | |
res1: String = bar | |
scala> c | |
res2: String = baz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://issues.scala-lang.org/browse/SI-7141