Mapped types in Scala similar to Typescript Pick, Exclude, etc
Asked Answered
C

0

7

Following on the heels of Mapped types in Scala

Is there a way to mimic Pick, Exclude, Diff and etc. from Typescript in Scala?

Using the a similar example as above:

case class Person(name: String, age: Int, address: String, phone: String)

is there a way to derive a type

class PersonSubset(name: String, age: Int)

without having to explicitly write out a separate case class?

As in following more of a Typescript approach, could we create a type alias that is a subset of fields of class Person?

Carmelo answered 14/1, 2020 at 4:7 Comment(1)
I'm interested in this too. Examples would be SELECT name, age FROM Person or GraphQL.Yemane

© 2022 - 2024 — McMap. All rights reserved.