1.xx.()->xx 这啥玩意啊
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
test { "" }
test { hello() }
test { zeze() }
test { zeze("what fuck~") }
}
fun test(block: MainActivity.() -> String) {
println(block)
}
}
fun MainActivity.hello(): String {
return "what fuck";
}
fun MainActivity.zeze(): String {
return "你好吗";
}
fun MainActivity.zeze(hell: String? = null): String {
return "你好吗$hell";
}
网友评论