KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Often you have "symmetric" matches and want to write things like: def g(p:(Int,Int)) = p match { case (10,n) | (n,10) => println(n) case _ => println("nope") } This is not allowed, but if every alternative has the same variables with the same types , this shouldn't be a problem, as it could be translated to separate cases: def g(p:(Int,Int)) = p match { case (10,n) => println(n) case (n,10) => println(n) case _ => println("nope") } So why do we have this restriction?
Tags (comma-separated)
Save Edits
Cancel