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
| This exercise looks tricky, but it's really one big `try` statement. | |
| Just call `untrustworthy` inside the `try`, and then use `on`, `catch`, | |
| and `finally` to catch exceptions and call methods on the logger. |
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
| Use the methods `map()`, `any()`, and `where()` to solve the exercise. |
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
| Use map to create a String with the user.name and the user.age |
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
| main() { | |
| var numbersByTwo = [1, -2, 3, 42].map((number) => number * 2); | |
| print('Numbers: $numbersByTwo.'); | |
| } |
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
| Use the `where` method to implement the filters. |
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
| main() { | |
| var numbers = [1, 3, -2, 0, 4, 5]; | |
| var numbersUntilZero = numbers.takeWhile((number) => number != 0); | |
| print('Numbers until 0: $numbersUntilZero'); | |
| var numbersAfterZero = numbers.skipWhile((number) => number != 0); | |
| print('Numbers after 0: $numbersAfterZero'); | |
| } |
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
| main() { | |
| var evenNumbers = [1, -2, 3, 42].where((number) => number.isEven); | |
| for (var number in evenNumbers) { | |
| print('$number is even.'); | |
| } | |
| if (evenNumbers.any((number) => number.isNegative)) { | |
| print('evenNumbers contains negative numbers.'); | |
| } |
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
| Use the methods `any` and `every` to compare the user age. |
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() { | |
| var items = ['Salad', 'Popcorn', 'Toast']; | |
| if (items.any((element) => element.contains('a'))) { | |
| print('At least one element contains "a"'); | |
| } | |
| if (items.every((element) => element.length >= 5)) { | |
| print('All elements have length >= 5'); | |
| } |
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
| Use the methods `contains` and `startWith` from the `String` class. |