Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
类定义如下所示:
abstract class EntityWithIdHelper[E <: { def id: Int }] { def idLens: Lens[E, Int] = GenLens[E](_.id) ...
你如何避免这个问题 - Cannot find method id in E?有什么解决方法吗?
Cannot find method id in E
你不能创建一个Lensforid因为 aLens需要一个 getter 和一个 setter,而这里你只有一个 getter。
Lens
id
此外,如果您想使用GenLens[E],E必须是一个案例类。
GenLens[E]
E