blob: e35b2e80e245cc37afc61addd3d68762cb07a95e [file] [log] [blame]
Jinseong Jeonbe754b12018-03-25 00:40:15 -07001// 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
5package non_null
6
7inline fun coalesce(a: String?, b: String?): String? = a ?: b
8fun aOrDefault(a: String?, default: String): String =
9 coalesce(a, default) ?: throw AssertionError()
10
11fun main(args: Array<String>) {
12 println(aOrDefault(null, "null"))
13 println(aOrDefault("null", "non-null"))
14}