Skip to content

Instantly share code, notes, and snippets.

@IhwanID
Created January 30, 2020 04:15
Show Gist options
  • Select an option

  • Save IhwanID/9ae29958cdeaf6de1301cb99e69abda6 to your computer and use it in GitHub Desktop.

Select an option

Save IhwanID/9ae29958cdeaf6de1301cb99e69abda6 to your computer and use it in GitHub Desktop.
tenary & if else
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