Created
February 2, 2015 15:52
-
-
Save ufcpp/71928d30896641df6939 to your computer and use it in GitHub Desktop.
Completeness for type pattern matching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Message { } | |
| class A : Message { } | |
| class B : Message { } | |
| class C : Message { } | |
| class PatternMatching | |
| { | |
| public static void Match(Message m) | |
| { | |
| if (m is A) { /* ... */ return; } | |
| if (m is B) { /* ... */ return; } | |
| if (m is C) { /* ... */ return; } | |
| // もう所望の全パターン網羅済み! | |
| // ここに来るはずがない! | |
| // というか、ここに来ない保証がほしい。 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment