- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
pattern matching problem
Wed, 2009-03-11, 15:56
hello,
I can't figure out what's going on in following code:
but when I uncomment line:
//case "0" :: "Vratene FA" :: _ => print("SendToLiquid")
it prints: no match which I don't understand I would still expect aacsave as a result
Thanks.
Peter Lopen
View this message in context: pattern matching problem
Sent from the Scala mailing list archive at Nabble.com.
object HistoryGeneratorCase { def main(args: Array[String]) { var t = List("0", "Na Archivaciu", "Na Archivaciu", "UHR_A", new Date().toString, new Date().toString) t match { //case "0" :: "Vratene FA" :: _ => print("SendToLiquid") case "0" :: SaveAndFlowCond(x) => print("csave") //case ::("0", SaveAndFlowCond(s)) => print("csave") case _ => print("no match") } } object SaveAndFlowCond { def unapply(next : List[String]) = { print("aa") next match { case "1" :: _ => Some(List("aa","bb")) case _ =>Some(List("aa","bb ")) } } } }when run, it prints: aacsave which is what I would expect
but when I uncomment line:
//case "0" :: "Vratene FA" :: _ => print("SendToLiquid")
it prints: no match which I don't understand I would still expect aacsave as a result
Thanks.
Peter Lopen
View this message in context: pattern matching problem
Sent from the Scala mailing list archive at Nabble.com.
On Wed, Mar 11, 2009 at 07:55:50AM -0700, beloved wrote:
> I can't figure out what's going on in following code:
It's a bug in the pattern matcher. I wish I could say I'm surprised,
but there are a whole pile of issues in the matcher when you start doing
"interesting" things - in this case, mixing case classes with
extractors. This is almost surely subsumed in some open bug, let's see
here... yes, I believe it's a variation on this one.
http://lampsvn.epfl.ch/trac/scala/ticket/1697
That the bugs aren't fixed does not reflect a lack of interest in doing
so, but the difficulty of fully understanding the pattern matcher.