How to have some members of a scala case class be private?
- User
How to have some members of a scala case class be private?
- Assistant
In Scala, you can't directly declare a field as private in a case class, because the main purpose of a case class is to provide public access to its parameters for pattern matching, equality, serialization, etc.
If you still want to encapsulate some fields, you can use a companion object or a regular class with a
copymethod andapply/unapplymethods in the companion object.Here is an example of how you might do it:
scala
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.