val date = new Date
val logWithDateBound = log(date, _ : String)
logWithDateBound("message1" )
If you want to change selection, open document below and click on "Move attachment"
Scala Partially Applied Functions ce. The result is a partially applied function that we've stored in a variable. We can now invoke this new method with only the unbound argument message as follows:
import java.util.Date
object Test {
def main(args: Array[String]) {
<span>val date = new Date
val logWithDateBound = log(date, _ : String)
logWithDateBound("message1" )
Thread.sleep(1000)
logWithDateBound("message2" )
Thread.sleep(1000)
logWithDateBound("message3" )
}
def log(date: Date, message: String) = {
Summary
status
not read
reprioritisations
last reprioritisation on
suggested re-reading day
started reading on
finished reading on
Details
Discussion
Do you want to join discussion? Click here to log in or create user.