Jinseong Jeon | be754b1 | 2018-03-25 00:40:15 -0700 | [diff] [blame] | 1 | // Copyright (c) 2018, the R8 project authors. Please see the AUTHORS file |
| 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. |
| 4 | |
| 5 | package non_null |
| 6 | |
| 7 | inline fun coalesce(a: String?, b: String?): String? = a ?: b |
| 8 | fun aOrDefault(a: String?, default: String): String = |
| 9 | coalesce(a, default) ?: throw AssertionError() |
| 10 | |
| 11 | fun main(args: Array<String>) { |
| 12 | println(aOrDefault(null, "null")) |
| 13 | println(aOrDefault("null", "non-null")) |
| 14 | } |