File: reify_maps_oldpatmat.scala

package info (click to toggle)
scala 2.11.12-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 62,924 kB
  • sloc: javascript: 28,808; java: 13,415; xml: 3,135; sh: 1,620; python: 756; makefile: 38; awk: 36; ansic: 6
file content (20 lines) | stat: -rw-r--r-- 567 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import scala.reflect.runtime.universe._
import scala.tools.reflect.Eval

object Test extends App {
  reify {
    val colors = Map("red" -> 0xFF0000,
                     "turquoise" -> 0x00FFFF,
                     "black" -> 0x000000,
                     "orange" -> 0xFF8040,
                     "brown" -> 0x804000)
    for (name <- List("red", "green", "blue", "turquoise")) println(
      colors.get(name) match {
        case Some(code) =>
          name + " has code: " + code
        case None =>
          "Unknown color: " + name
      }
    )
  }.eval
}