OLD | NEW |
1 // Copyright 2013 Google Inc. All Rights Reserved. | 1 // Copyright 2013 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 /** | 15 /// Simple code with broad use cases. |
16 * Simple code with broad use cases. | |
17 */ | |
18 library quiver.core; | 16 library quiver.core; |
19 | 17 |
| 18 import 'dart:collection'; |
| 19 |
20 part 'src/core/hash.dart'; | 20 part 'src/core/hash.dart'; |
21 part 'src/core/optional.dart'; | 21 part 'src/core/optional.dart'; |
22 | 22 |
23 /** | 23 /// Returns the first non-null argument. If all arguments are null, throws an |
24 * Returns the first non-null argument. If all arguments are null, throws | 24 /// [ArgumentError]. |
25 * an [ArgumentError]. | 25 /// |
26 * | 26 /// Note: if [o1] is an [Optional], this can be accomplished with `o1.or(o2)`. |
27 * Note: if [o1] is an [Optional], this can be accomplished with `o1.or(o2)`. | |
28 */ | |
29 firstNonNull(o1, o2, [o3, o4]) { | 27 firstNonNull(o1, o2, [o3, o4]) { |
30 if (o1 != null) return o1; | 28 if (o1 != null) return o1; |
31 if (o2 != null) return o2; | 29 if (o2 != null) return o2; |
32 if (o3 != null) return o3; | 30 if (o3 != null) return o3; |
33 if (o4 != null) return o4; | 31 if (o4 != null) return o4; |
34 throw new ArgumentError('All arguments were null'); | 32 throw new ArgumentError('All arguments were null'); |
35 } | 33 } |
OLD | NEW |