Created
February 13, 2016 09:22
-
-
Save dabd/673ad89c0185ad0c7085 to your computer and use it in GitHub Desktop.
This file contains 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
class Foo { | |
val quux = "quux" | |
def bar(baz: () => Unit): Foo = { | |
baz() | |
this | |
} | |
} | |
// I would like to write in fluent style like this but I can't reference the | |
// previous object in the chain | |
val qux = (new Foo).bar(() => println(s"${<how to reference new Foo here?>.quux}")) | |
// So I have to break it into two vals which is ugly | |
val qux = (new Foo) | |
val corge = qux.bar(() => println(s"${qux.quux}")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment