Skip to content

Instantly share code, notes, and snippets.

@yamashiro
Created May 30, 2012 06:45
Show Gist options
  • Save yamashiro/2834130 to your computer and use it in GitHub Desktop.
Save yamashiro/2834130 to your computer and use it in GitHub Desktop.
どういう変換が起こっているのかわからない…
import org.specs2.mutable._
class FunctionArgument {
def hoge(func: => AnyRef, condition:Boolean = true) : String = {
if (condition) {
func.toString
} else {
"false"
}
}
}
class FunctionArgumentTest extends Specification {
val target = new FunctionArgument()
"FunctionArgument " should {
"hoge can call " in {
target.hoge("aaa") must_== "aaa"
}
"hoge can call to pass false " in {
target.hoge("aaa", false) must_== "false"
}
"hoge can call with func " in {
def bbb() : String = { "bbb" }
target.hoge("aaa" + bbb) must_== "aaabbb"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment