Skip to content

Instantly share code, notes, and snippets.

@blast-hardcheese
Last active April 25, 2017 05:38
Show Gist options
  • Save blast-hardcheese/6715cea0a0b30b845081b67ebf6febee to your computer and use it in GitHub Desktop.
Save blast-hardcheese/6715cea0a0b30b845081b67ebf6febee to your computer and use it in GitHub Desktop.
scala> Foo.buildBar.baz(_, _)
res0: (Int, Int) => Int = <function2>
scala> res0(1,2)
Hello!
res1: Int = 3
scala> res0(1,2)
Hello!
res2: Int = 3
scala> val x = { val z = Foo.buildBar; z.baz(_, _) }
Hello!
x: (Int, Int) => Int = <function2>
scala> x(1,2)
res3: Int = 3
scala> x(1,2)
res4: Int = 3
scala> Foo.buildBar.baz _
buildBar
Hello!
res5: (Int, Int) => Int = <function2>
scala> res5(1,2)
res6: Int = 3
case class Bar() {
println("Hello!")
def baz(x: Int, y: Int): Int = x + y
}
object Foo {
def buildBar: Bar = Bar()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment