1

这两个定义有什么区别?

def f[F[_]: Async](...) = ???

def f[F[_]](...)(implicit F: Async[F]) = ???

稍后我可以Async[F].async {}在第一种情况和F.async {}第二种情况下使用但我无法弄清楚其中的区别。谢谢。

4

1 回答 1

1

I would say, it is just a matter of personal preference.

One is a syntactic sugar to other, You can go with any one of them and achieve same thing.

Note that, you are able to use this Async[F].async {} just because someone already defined apply method which looks similar to your second option.

If that was not the case, then you had to write it like implicitly[Async[F]].async {}

于 2020-09-11T07:27:50.037 回答