Created
January 30, 2020 04:15
-
-
Save IhwanID/9ae29958cdeaf6de1301cb99e69abda6 to your computer and use it in GitHub Desktop.
tenary & if else
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
| void main() { | |
| isOddOrEven(18); | |
| } | |
| void isOddOrEven(int number){ | |
| if(number % 2 == 0){ | |
| print("$number is even"); | |
| }else{ | |
| print("$number is odd"); | |
| } | |
| //tenary option | |
| final type = (number % 2 == 0) ? 'even': 'odd'; | |
| print("$number is $type ;)"); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment