Created
September 18, 2012 08:07
-
-
Save Rogach/3741938 to your computer and use it in GitHub Desktop.
File to test highlighting upon
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
package simple | |
package even.simpler | |
import scala.collection._ | |
import scala.util.{Random => Rnd} | |
import scala.collection.mutable.Map | |
object Simple { | |
type TP = Seq[String] | |
val char = 'a' | |
val symbol = 'a | |
var double = 2.3d | |
@volatile var string = "" | |
val hex = 0x100 | |
val octal = 077 | |
val `package` = """strange""" | |
val functionLiteral = (key: String) => key.size | |
val functionLiteral_2: String => Int = _.size + 1 | |
"a" match { | |
case "a" => 1 | |
case "b" => 2 | |
} | |
class Apple { | |
def add(i: Int) = i + 2 | |
} | |
new Apple | |
new Apple { | |
override def add(i: Int) = i + 3 | |
} | |
class Banana[T] extends Apple { | |
def eat(i: Double) = 1 - i | |
} | |
new Banana | |
new Banana[Int] | |
new Banana[Int]() | |
new Banana[String] { | |
def haul = "Yieee!" | |
} | |
class Coconuts(count: Int) extends Apple { // yes, something is not exactly right about such inheritance. But why not? | |
def crack = List.fill(count)(new Apple) | |
def eat[C](implicit c: Int = 2) = List.fill(c)(crack).flatten | |
} | |
new Coconuts(3) | |
(new Coconuts(5)).crack | |
trait Res | |
case object Exit extends Res | |
case object Help extends Res | |
(Exit:Res) match { | |
case Help if math.random > 0.5 => 1 | |
case Exit => 2 | |
case _ => 3 | |
} | |
Option(5) match { | |
case Some(x) => println(x) | |
case None => println("none!") | |
} | |
def run: Int = { | |
return 42 | |
} | |
def fail = { | |
throw new Exception("!") | |
} | |
val arr = Array[String]("a", "b", "c") | |
arr(0) | |
arr(2) = "d" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment