!SLIDE
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
scala> val gt10: Int => Boolean = (n: Int) => n > 10 | |
gt10: Int => Boolean = <function1> | |
scala> val lt5: Int => Boolean = (n: Int) => n < 5 | |
lt5: Int => Boolean = <function1> | |
scala> 0 to 15 filter (lt5 |+| gt10) | |
res35: scala.collection.immutable.IndexedSeq[Int] = Vector(0, 1, 2, 3, 4, 11, 12, 13, 14, 15) | |
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
interface Function1<T, U> { | |
U apply(T t); | |
} | |
interface Optional<T> { | |
T get(); | |
T getOrElse(T defaultValue); | |
boolean isDefined(); | |
<U> Optional<U> map(Function1<T, U> f); | |
} |
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 com.github.tototoshi.example | |
import scala.xml.{ NodeSeq, Elem } | |
import dispatch._ | |
import net.liftweb._ | |
import common._ | |
import util._ |
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
import scala.xml._ | |
import scala.util.parsing.combinator._ | |
trait SelectorParser extends RegexParsers { | |
val html: NodeSeq | |
def tagSelector(tag: String)(filter: NodeSeq => Boolean): NodeSeq = html \\ tag filter filter | |
def idFilter(id: String): NodeSeq => Boolean = (n: NodeSeq) => (n \ "@id" text) == id |
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
// see: https://github.com/szeiger/scala-query/blob/0.9.5/src/main/scala/org/scalaquery/ql/basic/BasicColumnOptions.scala | |
package com.github.tototoshi.example | |
import org.scalaquery._ | |
import session.{ Database, Session } | |
import ql._ | |
import basic.BasicDriver.Implicit._ | |
import basic.{ BasicTable => Table } |
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
#!/bin/sh | |
exec scala "$0" "$@" | |
!# | |
val helpMessage = """ | |
Usage: | |
-n do not output the trailing newline | |
-x repeat x times |
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
import java.util.NoSuchElementException | |
import scala.util.control.Exception._ | |
import org.scalatra._ | |
trait SafeParams { self: ScalatraKernel => | |
def paramsSafely(key: String): Option[String] = { | |
catching(classOf[NoSuchElementException]).opt { | |
params(key) | |
} |
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
import org.specs2.mutable._ | |
class AfterComposeSpec extends Specification { | |
"Compose After" should { | |
"after123" in (After1 then After2 then After3){ | |
success | |
} |
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
/* これはできる */ | |
val o = Some(("foo", 1)) | |
for { | |
(s, i) <- o | |
} yield { | |
println(s) | |
println(i) | |
} |