alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (run-bug4840.scala)

This example Scala source code file (run-bug4840.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

any, array, boolean, int, int, none, none, option, some, some, test, test, unit

The Scala run-bug4840.scala source code

object Test {
  def g(x: Boolean): Option[String] = if (x) Some("booya") else None
  
  def f1() = {
    for (x <- g(true)) yield {
      g(false) match {
        case Some(_) => sys.error("")
        case None    => 5
      }
    }
  }
  
  def f2() = {
    for (x <- g(true) ; y <- g(true) ; z <- g(true)) yield {
      for (x <- g(true) ; y <- g(true) ; z <- g(true)) yield {
        g(true) map { _ => 
          (null: Any) match {
            case Some(x: Int) => x
            case _            => 5
          }
        }
      }
    }
  }  

  def main(args: Array[String]): Unit = {
    println(f1())
    println(f2())
  }
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala run-bug4840.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.