How can I take any function as input for my Scala wrapper method?
Posted
by pr1001
on Stack Overflow
See other posts from Stack Overflow
or by pr1001
Published on 2010-04-17T09:45:42Z
Indexed on
2010/04/17
9:53 UTC
Read the original article
Hit count: 215
Let's say I want to make a little wrapper along the lines of:
def wrapper(f: (Any) => Any): Any = {
println("Executing now")
val res = f
println("Execution finished")
res
}
wrapper {
println("2")
}
Does this make sense? My wrapper method is obviously wrong, but I think the spirit of what I want to do is possible. Am I right in thinking so? If so, what's the solution? Thanks!
© Stack Overflow or respective owner