1

使用这样的解决方案可以吗:

def convert[T](x: T)(implicit format = Default) = ...

如果不需要,它允许您不指定隐式。但是许多库(至少 Lift Json 和 Scala Concurrent)避免了这种默认的隐式值,并推动用户始终指定隐式。对图书馆设计师有什么建议吗?

4

1 回答 1

0

Retroonym 顺便说一句:

https://groups.google.com/d/msg/scala-user/6MudBXELxVQ/ul67d5Rh4b4J

可以说用默认值定义隐式参数的风格很差

比较:

隐式参数 VS 默认参数值

这是一个很好的:

https://stackoverflow.com/a/20016152/1296806

于 2014-09-18T20:48:29.567 回答