Tag: 查找

高效的交换机需要自我资格?

显然, when表达式根据一个表示常量的不同而编译when object SwitchOverConstants { val foo = 1 val bar = 2 val baz = 3 fun one(x: Int) = when (x) { foo -> "foo" bar -> "bar" baz -> "baz" else -> "else" } fun two(x: Int) = when (x) { SwitchOverConstants.foo -> "foo" SwitchOverConstants.bar -> "bar" SwitchOverConstants.baz -> "baz" else -> […]