object CurryingTest {
def summary() {
println("---summary start---")
println("--- summary end ---")
}
def details() {
println("---start usage start---")
println("--- start usage end ---")
println("---restart usage start---")
println("--- restart usage end ---")
println("---stop usage start---")
println("--- stop usage end ---")
println("---status usage start---")
println("--- status usage end ---")
}
def usage[T](summary: => T)(details: => T): Unit = {
println("---usage start---")
summary
println("-----------------")
details
println("--- usage end ---")
}
def main(args: Array[String]) {
usage(summary())(details())
}
}
>scalac -d classes CurryingTest.scala
>scala CurryingTest
---usage start---
---summary start---
--- summary end ---
-----------------
---start usage start---
--- start usage end ---
---restart usage start---
--- restart usage end ---
---stop usage start---
--- stop usage end ---
---status usage start---
--- status usage end ---
--- usage end ---
def summary() {
println("---summary start---")
println("--- summary end ---")
}
def details() {
println("---start usage start---")
println("--- start usage end ---")
println("---restart usage start---")
println("--- restart usage end ---")
println("---stop usage start---")
println("--- stop usage end ---")
println("---status usage start---")
println("--- status usage end ---")
}
def usage[T](summary: => T)(details: => T): Unit = {
println("---usage start---")
summary
println("-----------------")
details
println("--- usage end ---")
}
def main(args: Array[String]) {
usage(summary())(details())
}
}
>scalac -d classes CurryingTest.scala
>scala CurryingTest
---usage start---
---summary start---
--- summary end ---
-----------------
---start usage start---
--- start usage end ---
---restart usage start---
--- restart usage end ---
---stop usage start---
--- stop usage end ---
---status usage start---
--- status usage end ---
--- usage end ---