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
| 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
| 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 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 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
| 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
| 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
| <!DOCTYPE html> | |
| <!-- | |
| Copyright (c) 2012, the Dart project authors. | |
| Please see the AUTHORS file for details. | |
| All rights reserved. Use of this source code | |
| is governed by a BSD-style license that can be | |
| found in the LICENSE file. | |
| --> | |
| <html> |
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
| <!DOCTYPE html> | |
| <!-- | |
| Copyright (c) 2012, the Dart project authors. | |
| Please see the AUTHORS file for details. | |
| All rights reserved. Use of this source code | |
| is governed by a BSD-style license that can be | |
| found in the LICENSE file. | |
| --> |
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
| <!DOCTYPE html> | |
| <!-- | |
| Copyright (c) 2012, the Dart project authors. | |
| Please see the AUTHORS file for details. | |
| All rights reserved. Use of this source code | |
| is governed by a BSD-style license that can be | |
| found in the LICENSE file. | |
| --> | |
| <html> |