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