Created
August 10, 2018 02:55
-
-
Save mildocjr/619aebdacbf27d709ec1f27f6aaba87d to your computer and use it in GitHub Desktop.
ternary-operators-3
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
| var isSunShining = true | |
| var description: String = "" // This is an empty string | |
| if isSunShining { | |
| description = "Yay!" | |
| else { | |
| description = "Aww..." | |
| } | |
| // Same if statement using a ternary operator | |
| description = isSunShining ? "Yay!" : "Aww..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment