Skip to content

Instantly share code, notes, and snippets.

@aslakhellesoy
Created August 3, 2009 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save aslakhellesoy/160587 to your computer and use it in GitHub Desktop.
Save aslakhellesoy/160587 to your computer and use it in GitHub Desktop.
// How to combine this method declaration....
def Given(name: String, body: Function2[Int, String, Unit]): Unit = {
body.apply(5, "belly")
}
// ...and this method declaration to one polymorphic declaration...
def Given(name: String, body: Function1[String, Unit]): Unit = {
body.apply("bob")
}
// ...that can be invoked like this...
Given("I have (\\d+) cukes in my (.*)", (cukes:Int, where:String) => {
println("You have " + cukes + " cukes in your " + where)
})
// ...and this
Given("my name is (.*)", (name:String) => {
println("Your name is " + name)
})
// Similar to this Groovy example: http://gist.github.com/160492
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment