I'm new to scala macros and I spent a couple of days trying to write my very first one. I have a problem with quasiquotes concatenation.
There is a list of case clauses, let's say the following:
val cases = cq"x => 1 " :: cq"_ => 0 " :: Nil
And I need to build a partial function from it. The problem is that I don't have an idea how to paste them in the final quasiquote. The documentation says I should do something like this:
q"{ case ..$cases }"
but it doesn't work if I do so.
Is there a way to build a PartialFunction from such a list?
Thanks for any help.
x => 1
mathes any expression, if you are referencing to some local value namedx
you should use`x` => 1
as patern – Parabolic