문제

Let's say I'm defining some cases to match, where I care only about verifying an argument:

BytecodeChains.partial {
    case CallProperty(name, args) if name == someConstant => xxx
} ....

where the function signature is:

BytecodeChains.partial[A] (f: PartialFunction[AbstractOp, A]): ...

How can I return the whole matched CallProperty object? I could create a new one, but that's a bit ugly. Is there some way to reference the original in place of xxx?

도움이 되었습니까?

해결책

case xxx @ CallProperty(name, args) if name == someConstant => xxx

You can also do this btw:

case xxx @ CallProperty(`someConstant`, args) => xxx

다른 팁

Is this what you are looking for?

case c @ CallProperty(name, args) if name == someConstant => c
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top