How do you code up a pattern matching code block in scala?
Posted
by egervari
on Stack Overflow
See other posts from Stack Overflow
or by egervari
Published on 2010-05-10T04:53:48Z
Indexed on
2010/05/10
5:18 UTC
Read the original article
Hit count: 296
How do you code a function that takes in a block of code as a parameter that contains case statements? For instance, in my block of code, I don't want to do a match or a default case explicitly. I am looking something like this
myApi {
case Whatever() => // code for case 1
case SomethingElse() => // code for case 2
}
And inside of my myApi(), it'll actually execute the code block and do the matches. Help?
© Stack Overflow or respective owner