I have a project based on ScalaJS and upickle. This means I do not have access to Scala reflection in my code on the JS side. I have a need to associate case class attributes with their names and am wondering if there is any way I can infer the name from the attribute.
So say I have the following code:
case class A(attr1: String, attr2: Int)
def foo[T, U](get: T => U, name: String) = { ... }
foo[A, String](_.attr1, "attr1")
foo[A, Int](_.attr2, "attr2")
I am wondering if there is a way I can define foo without needing to pass the actual name of the attribute?
ie something like
def foo[T,U](get: T => U) { // infer the name of the attribue ... }
Note that I have access to upickle's Reader and Writer objects for the given class so am wondering if there is a useful capability there?