10 Jul 2012 02:42
Re: The Option conundrum
On Mon, Jul 9, 2012 at 8:44 PM, Rex Kerr <ichoran@...> wrote: > > There is one other use-case that you may be forgetting, however: pattern > matching. This is a problem whether or not Some(null) is permitted: > > val a: Any = Some("fish") > val b: Any = "fish" > List(a,b).foreach(_ match { > case Some(x) => println("Some") > case x => println("Just the item.") > }) My understanding is that Option would be made to extend AnyVal, and, therefore, AnyVal rules would (mostly) apply. In such a case, "a" would contain the reference to Some("fish"), since optimization at that point would no longer be possible. -- -- Daniel C. Sobral I travel to the future all the time.
RSS Feed