Skip to content

Instantly share code, notes, and snippets.

@Rogach
Created September 18, 2012 08:07
Show Gist options
  • Save Rogach/3741938 to your computer and use it in GitHub Desktop.
Save Rogach/3741938 to your computer and use it in GitHub Desktop.
File to test highlighting upon
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