switch on tuple
See original GitHub issue[@gavinking] We still don’t have any real plans to support genuine pattern matching, however one small thing that could I guess make some sense would be to allow tuple expressions in a case
, for example:
switch(tuple)
case ([0,false]) { ... }
case ([1,true]) { ... }
case ([1,false]) { ... }
else { ... }
This would only be for tuples of types that we already allow in case
s.
[Migrated from ceylon/ceylon-spec#1021]
Issue Analytics
- State:
- Created 9 years ago
- Comments:57 (47 by maintainers)
Top Results From Across the Web
How to use c# tuple value types in a switch statement
You can't use a tuple as a switch value, switch only accepts constant values. – Gusman. Jun 4, 2017 at 15:27. @Gusman Not ......
Read more >Do more with patterns in C# 8.0 - .NET Blog
A very useful special case of positional patterns is when they are applied to tuples. If a switch statement is applied to a...
Read more >Tuples and Switch Statements in Swift Programming Language
Tuples can also be used in Switch statement, either by themselves (normal equality check), or along with underscores and where clauses to construct...
Read more >Switches on tuple values - Swift - Java2s.com
When writing a tuple switch you'll require a default case. Related Topic. Switches · Switches with range · Switches without break · Switches...
Read more >Working With Switch Expressions And Pattern Matching In C# ...
As you can see in the above code the tuple value is being compared and the expression of matching tuple value is being...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think it would be weird and irregular to not allow
case([])
.===
is fine, I guess.