Case classes are regular classes which export their constructor parameters and which provide a recursive decomposition mechanism via pattern matching.
Questions tagged [case-class]
711 questions
-2
votes
1 answer
How to read from a case class in Scala?
I am new to Scala. I have a case class. The code is given below.
case class ReportInfoPosted(
name: Option[String],
id: Option[String],
order: Option[Int]
)
I also have a function which returns an seq of objects of the class. This is what…

odbhut.shei.chhele
- 5,834
- 16
- 69
- 109
-2
votes
1 answer
Cannot extract data from json with more than 22 fields in scala 2.10
I am trying to extract values from the json dataset where each record has n > 22 key-value pairs. In order to do so, I implemented a case class with n member variables. However, the scala 2.10.x compiler reported "Implementation restriction: case…

yxjiang
- 240
- 1
- 4
- 8
-3
votes
2 answers
Scala Filtering List of Case Class
Suppose you have a case class like below
case class Fruit(name: String, color: String, price: Double){
}
and you also have list of case class
val Fruits = List
(Fruit("Apple", "red", 3.00), Fruit ("Banana", "yellow", 4.99))
How do you filter based…

James
- 17
- 7
-3
votes
1 answer
Scala case class vs object: how is it instantiated?
Some context so that this question actually makes some sense.
I have a trait from which I extend a case class and an object.
I have a method that pattern matches to decide which to pull based on given conditions.
When I pattern match and get the…

trashbear
- 109
- 5
-3
votes
1 answer
Create a JSON object using the scala case class
I've the JSON file as shown below, my scala program has to read this JSON file as an args(0) and for args(1) i will be passing CUSTOMER_VEHICLE as an argument. Based on the args(1) argument passed, program has to fetch the corresponding staginDir…

chaitra k
- 371
- 1
- 4
- 18
-4
votes
1 answer
Scala create group of elements
I want to create a group of elements in a message as in below image
Updated:
case class Element(key:String;value:String)
Message can be represented something like below
case class Msg(field1:Element,field2:Group)
Group->represents the…

coder25
- 2,363
- 12
- 57
- 104