Created
June 20, 2022 18:01
-
-
Save ntatko/6be8a4c4a4a79afe07583e48478d69d4 to your computer and use it in GitHub Desktop.
Logical Operators in Dart example
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
| /// LOGICAL OPERATORS | |
| void main() { | |
| // && | |
| bool first = (true) && (true); // true | |
| bool second = (true) && (false); // false | |
| List array = [1, 2, 3]; | |
| Map map = {}; | |
| bool theyAreBothEmpty = array.isEmpty && map.isEmpty; // false | |
| bool theyAreBothNotEmpty = array.isNotEmpty && map.isNotEmpty; // false | |
| bool thirdCase = array.isNotEmpty && map.isEmpty; // true | |
| // || | |
| bool third = (false) || (false); // false | |
| bool fourth = (true) || (false); // true | |
| bool fifth = (true) || (true); // true | |
| List array2 = [1, 2, 3]; | |
| Map map2 = {}; | |
| bool oneIsEmpty = array2.isEmpty || map2.isEmpty; // true | |
| bool oneIsNotEmpty = array2.isNotEmpty || map2.isNotEmpty; // true | |
| bool mixed = array2.isNotEmpty || map.isEmpty; // true | |
| bool willBeFalse = array2.isEmpty || map2.isNotEmpty; // false | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment