I often find that I want to combine several elements / extractors into one line, but this does not seem to be allowed. eg:.
text match { case regex1(a) | regex2(a) => a + "-" }
(although a
is the same type for both sockets)
so I am forced to reorganize like this (which can become ugly if there are several of them, all are handled by different matches mixed with inline answers)
text match { case regex1(a) => op(a) case regex2(a) => op(a) } def op(a: String) = a + "-"
Is there a cleaner way? And will it be supported in Scala in the future?
source share