| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library collections; | 5 library collections; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Returns the concatentation of the input iterables. | 8 * Returns the concatentation of the input iterables. |
| 9 * | 9 * |
| 10 * The returned iterable is a lazily-evaluated view on the input iterables. | 10 * The returned iterable is a lazily-evaluated view on the input iterables. |
| 11 */ | 11 */ |
| 12 Iterable concat(Iterable<Iterable> iterables) => iterables.expand((x) => x); | 12 Iterable concat(Iterable<Iterable> iterables) => iterables.expand((x) => x); |
| 13 | 13 |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Returns the concatentation of the input iterables as a [List]. | 16 * Returns the concatentation of the input iterables as a [List]. |
| 17 */ | 17 */ |
| 18 List concatToList(Iterable<Iterable> iterables) => concat(iterables).toList(); | 18 List concatToList(Iterable<Iterable> iterables) => concat(iterables).toList(); |
| 19 |
| 20 |
| 21 /** |
| 22 * Returns the given [list] if it is not empty, or `null` otherwise. |
| 23 */ |
| 24 List nullIfEmpty(List list) { |
| 25 if (list == null) { |
| 26 return null; |
| 27 } |
| 28 if (list.isEmpty) { |
| 29 return null; |
| 30 } |
| 31 return list; |
| 32 } |
| OLD | NEW |