区别:回调函数里面的this作用域不同,也就是this所指向的对象不同。

1. T.() -> Unit 作为参数  //回调函数里this作用域是 类型T的实例
public inline fun <T> T.extFunc(block: T.() -> Unit): T {
block()
return this
}

2.() -> Unit 作为参数  //回调函数里this作用域是 调用该函数所在的实例
public inline fun <T> T.extFunc(block: () -> Unit): T {
block()
return this
}

相关文章:

  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-05
  • 2021-06-01
  • 2022-03-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
相关资源
相似解决方案