kotlin.String!
类型的含义是什么?我怎样才能编译下面的代码?
fun withDefault<A>(computation: () -> A, default: A) =
try { computation() } catch (e: Exception) { default }
fun getHostname1() = withDefault(InetAddress.getLocalHost().getCanonicalHostName, "localhost")
编译器将打印以下错误消息:
Kotlin: Type inference failed: fun <A> withDefault(computation: () -> A, default: A): A
cannot be applied to
(kotlin.String!,kotlin.String)