Last active
August 29, 2015 14:14
-
-
Save ufcpp/896d67cc0841db74c422 to your computer and use it in GitHub Desktop.
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
| public static void ShowBattleAction(BattleAction action) | |
| { | |
| var heal = action as Heal; | |
| if (heal != null) ShowHeal(heal); | |
| var attack = action as Attack; | |
| if (attack != null) ShowAttack(attack); | |
| } |
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
| public static void ShowBattleAction(BattleAction action) | |
| { | |
| if (action is Heal heal) ShowHeal(heal); | |
| else if (action is Attack attack) ShowAttack(attack); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment