Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
trait FancyTrait {
def withContext(method: => () => Unit) = {
// define some context here, like:
val sender = this.sender
// run the method which can see the context
method()
}
}
class PimpedOutClass extends FancyTrait {
def doStuff = {
withContext {
sender ! "fun message sent to a variable brought into scope by withContext"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.