// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package basic

import java.io.IOException

object Control {
  def even = for(i <- 1 to 20 if(i % 2 == 0)) yield i
  def test(o: Any): Unit = o match {
    case v: Int => println("integer " + v)
    case v: String => println("string " + v)
    case null => println("null")
    case _ => println("unknown")
  }
  def main(args: Array[String]): Unit = {
    for(i <- even) println(i)
    try {
      throw new Exception("Test")
    } catch {
      case ex: IOException => println("IOE")
      case ex: Exception => println("E")
      case ex: Throwable => println("T")
    }
    test(123)
    test("ABC")
    test(null)
    test(new Exception("E"))
  }
}
