[英]scala- ways to find implicit execution context in use by a scala program
I have a scala class taking implicit execution-context parameter, in play-framework based application.我有一个 scala class 在基于播放框架的应用程序中采用隐式执行上下文参数。 At runtime of this play application, is there a way to see list of implicits(along with names) used by a class?
在这个播放应用程序的运行时,有没有办法查看 class 使用的隐式列表(连同名称)? Appreciate any input.
感谢任何输入。
At runtime, you can summon an implicit via implicitly[T]
, eg在运行时,您可以通过
implicitly[T]
调用隐式,例如
println(implicitly[ExecutionContext])
This probably won't give you the name that context has been bound to.这可能不会为您提供上下文绑定的名称。 As for a list, well, at runtime there's at most one instance of any given type in the implicit scope at a point in time (and the same is true at compile time for a given location in the code), so a list wouldn't be much value.
至于列表,嗯,在运行时,隐式 scope 在某个时间点至多有一个任何给定类型的实例(在代码中给定位置的编译时也是如此),所以列表不会价值不大。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.