How can I create a custom method with path?
user753 opened this issue · 0 comments
user753 commented
I have something like this
case class State(foo: Int)
class Store {
var state = State(100)
inline def set[A](inline path: State => A, value: A): Unit = {
state = modify(state)(path).setTo(value)
}
}
I what to implement set
method so I could use it like this set(_.foo, 200)
But there is an error
set(_.foo, 200)
^^^^^^^^^
Unsupported path element. Path must have shape: _.field1.field2.each.field3.(...), got: ((_$16: State) => _$16.foo)
Is there any way to do it?