score:2
as the tour of scala or the scala 3 book says
when you create a case class with parameters, the parameters are public
val
s.
therefore, in
case class person(name: string, age: int)
both name
and age
will be public, unlike in an ordinary class.
Source: stackoverflow.com
Related Query
- Are constructor parameters treated differently in classes vs. case classes?
- Why are constructor parameters made into members for case classes?
- Are case class constructor parameters public val fields by default?
- Why are case objects serializable and case classes not?
- How can I create an instance of a Case Class with constructor arguments with no Parameters in Scala?
- Scala Case Classes - Are they just structs?
- Recursive transformation between nested case classes where the fields in the target are unaligned subsets of the source class
- Derived classes as class constructor parameters
- Pre-process parameters of a case class constructor without repeating the argument list
- Matching case classes without parameters list
- Abstract classes with constructor parameters in Scala
- Spark JSON reading fields that are completional in JSON into case classes
- Why scala serializability differs in case classes with same constructor parameter types?
- Trying to understand how classes declared on the REPL are treated internally
- Case classes with inheritance and default parameters
- Scala's case class and its constructor parameter passing to super classes
- Scala constructor for case classes question
- Case Classes w/ Option Parameters & Case Matching
- Matching only some parameters in case classes and not put N place holder for all options
- Why are non case classes allowed to inherit sealed classes?
- Merging case classes if the values are None
- Build, using Shapeless, generic default instances for case classes with parameters defining a common createValue method
- Shapeless. Refer to all case classes of 1 constructor argument
- case class explicit parameters that are implicit inside
- How can I use Json.reads to deserialize JSON into a case class with optional constructor parameters
- case classes in scala does not accept more than 22 parameters
- What are the practical benefits of marking case classes as final in scala
- Convert case class constructor parameters to String Array in Scala
- How to initialize parent case class parameters in constructor
- How to restrict that case classes have specific parameter types constructor in Scala?
More Query from same tag
- What is 'Activator' as mentioned in this blog?
- Guidance on play's execution context and creating my jdbc thread pool
- Setting up actions for multiple test folders in SBT
- Akka Scala actor scheduled message does not appear to fire
- Play 2.0 Nested forms: generate <input id="email"> instead of <input id="user_email">
- Scala methods ending in _=
- Scala - tuple type inference fail?
- How to publish data to using MQTT
- how to creat spark dataframe from a Map(string,any) scala?
- Can a scala self-type be satisfied via delegation?
- pattern matching gives return type as Any
- Getting Streaming window timestamp for spark
- How to use ~> and <~ in grammar rule definition in Scala?
- STS - Scala project not showing up
- scala - play json JsValue conver to generic type
- Is there something like npmjs for Scala / Java
- scala polymorphic type for return value
- Django tags and filters in Lift?
- How to add a element inside an element in a struct which is a element in struct in a spark Dataframe in spark scala
- A future buried deep inside a chain of conditionals with a common "else" future
- toChar is not a value of Unit
- how to make sbt portable?
- pairing each RDD value with all the other values in RDD in scala
- Using PureConfig with Refined?
- How do I use Scala dispatch to get the URL returned in a 301 redirect?
- How to get the runtime value of parameter passed to a Scala macro?
- How to further improve error messages in Scala parser-combinator based parsers?
- SparkSql Catalyst extending Analyzer, Error with CatalystConf
- Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/rdd/RDD
- How to define table name at runtime using quill