Skip to content

Instantly share code, notes, and snippets.

@AAQ-AND-DEV
Created March 21, 2019 01:39
Show Gist options
  • Save AAQ-AND-DEV/b8dbd61261f8b62f9fb1dd2bf665639b to your computer and use it in GitHub Desktop.
Save AAQ-AND-DEV/b8dbd61261f8b62f9fb1dd2bf665639b to your computer and use it in GitHub Desktop.
booleans and logical operators (XOR, OR, AND)
void main() {
String name = "James";
String lastName = "Bond";
int age = 45;
print('his name is ${name + ' ' + lastName} he is $age years old');
print('his name is $name $lastName he is $age years old');
print('${lastName.toUpperCase()}');
bool isTheBest = false;
bool isTheGreatest = false;
bool isTheWorst = true;
bool isReallyBad = true;
print("logical AND");
//logical conjunction -- true if both true, otherwise false
print(isTheBest & isTheWorst);
print(isTheBest & isTheGreatest);
print(isTheWorst & isReallyBad);
print("xor");
//exclusive or -- returns whether neither both true nor both false
print(isTheBest ^ isTheWorst); //predict true
print(isTheBest ^ isTheGreatest); // predict false
print(isTheWorst ^ isReallyBad); //predict false
print("inclusive OR");
//inclusive or |
print(isTheBest | isTheWorst); //predict true
print(isTheBest | isTheGreatest); //predict false
print(isTheWorst | isReallyBad); //predict true
print('${lastName.toUpperCase()} is $isTheBest');
print('${lastName is String}');
print('$isTheBest');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment