case-class Questions
7
Solved
Is there an easy way to convert a case class into a tuple?
I can, of course, easily write boilerplate code to do this, but I mean without the boilerplate.
What I'm really after is a way to easily...
Coraliecoraline asked 10/11, 2011 at 23:42
7
Solved
Scala case classes have a limit of 22 fields in the constructor. I want to exceed this limit, is there a way to do it with inheritance or composition that works with case classes?
Brimmer asked 28/11, 2013 at 5:32
1
Solved
I'd like to be able to store different related types in a Spark DataFrame but work with strongly typed case classes via a DataSet. E.g. say I have a Base trait and two case classes A and B that ext...
Freidafreight asked 15/4 at 21:18
2
Solved
Assuming you have case classes like the following
case class Test1(a:String,b:Int,c:Char)
case class Test2(a:String,b:Int)
And you instantiate the classes with the following variables
val test...
Petrolatum asked 21/4, 2014 at 7:17
4
Solved
In Scala, suppose I have a case class like this:
case class Sample(myInt: Int, myString: String)
Is there a way for me to obtain a Seq[(String, Class[_])], or better yet, Seq[(String, Manifest)]...
Randa asked 8/6, 2011 at 17:0
4
If I have the following case class with a private constructor and I can not access the apply-method in the companion object.
case class Meter private (m: Int)
val m = Meter(10) // constructor Met...
Cling asked 17/11, 2013 at 12:47
12
Solved
Is there a nice way I can convert a Scala case class instance, e.g.
case class MyClass(param1: String, param2: String)
val x = MyClass("hello", "world")
into a mapping of some kind, e.g.
getCCP...
Grisham asked 4/8, 2009 at 9:40
11
Solved
I'm making a parser with Scala Combinators. It is awesome. What I end up with is a long list of entagled case classes, like: ClassDecl(Complex,List(VarDecl(Real,float), VarDecl(Imag,float))), just ...
Are asked 30/3, 2013 at 12:27
17
Solved
I searched in Google to find the differences between a case class and a class. Everyone mentions that when you want to do pattern matching on the class, use case class. Otherwise use classes and al...
Applegate asked 22/2, 2010 at 17:49
7
Solved
I have a list of simple scala case class instances and I want to print them in predictable, lexicographical order using list.sorted, but receive "No implicit Ordering defined for ...".
Is there ex...
Sophy asked 13/10, 2013 at 12:9
3
Solved
I'm writing a type-safe code and want to replace apply() generated for case classes with my own implementation. Here it is:
import shapeless._
sealed trait Data
case object Remote extends Data
cas...
Heterolysis asked 20/10, 2020 at 21:10
10
Solved
So here's the situation. I want to define a case class like so:
case class A(val s: String)
and I want to define an object to ensure that when I create instances of the class, the value for 's' ...
Scenarist asked 29/4, 2011 at 3:25
1
Solved
I'm trying to copy() a Scala case class which has a type param. At the call site, the type of the value is Foo[_].
This compiles as expected:
case class Foo[A](id: String, name: String, v1: Bar[A])...
Heber asked 13/7, 2020 at 10:15
2
Solved
Defined empty trait Test:
trait Test
what used in compound type:
scala> val a : Int with Test = 10.asInstanceOf[Int with Test]
a: Int with Test = 10
and case class with parameter of compou...
Gond asked 20/11, 2013 at 11:28
1
I have a case class with many members, two of which are non-primitive:
import com.twitter.util.Duration
case class Foo(
a: Int,
b: Int,
...,
y: Int,
z: Int,
timeoutSeconds: Duration,
runtim...
Bridgework asked 29/11, 2014 at 4:35
1
Solved
Assume I have case class with several field members:
case class User(name: String, ..., createdAt: LocalDateTime)
How could I check equality without taking into account createdAt field?
Is there a...
Time asked 12/2, 2020 at 23:5
4
Solved
Is there a elegant way to convert a case class to a CSV value.
For example -
case class Person( name : String, age : Int, gender: String, address : Option[String])
I was thinking about using ...
Underact asked 16/5, 2015 at 4:25
3
Solved
I have a case class with 2 String members. I would like to update The second member later, so first I create an instance with String and None and later I load the data to the class and would like t...
Obstacle asked 8/6, 2014 at 11:1
1
Solved
Suppose there is a Scala case-class Point
case class Point(x: Int, y: Int)
One can use a wildcard for matching:
val p = new Point(1,2)
val inRightHalfPlane = p match {
case Point(x, _) i...
Entozoon asked 8/5, 2019 at 15:28
2
Solved
I wrote the following:
case class SuperMessage(message: String)(capitalMessage: String = message.capitalize)
val message = "hello world"
val superMessage = SuperMessage(message)()
but I can't do...
Ferret asked 14/4, 2019 at 20:35
4
Solved
Is there any way to easily parse a string of key value pairs into a scala case class?
For example from the following string:
"consumer_key=1234ABC, consumer_secret=12345ABC"
into
case class Au...
Kampala asked 25/10, 2012 at 13:30
0
I have an Enumeratum enum and need to load it into a spark data frame. Obviously, this fails due to a missing encoder.
import enumeratum._
sealed trait Foo extends EnumEntry
object Foo extends En...
Ultracentrifuge asked 2/4, 2019 at 22:39
3
How should I extract the value of a field of a case class from a given String value representing the field.
For example:
case class Person(name: String, age: Int)
val a = Person("test",10)
Now ...
Innkeeper asked 7/8, 2017 at 13:15
1
Solved
I have defined a couple of case classes for JSON representation but I am not sure whether I did it properly as there a lot of nested case classes.
Entities like spec, meta and so on are of type JSO...
Require asked 11/1, 2019 at 16:0
14
Solved
Are there any best-practice guidelines on when to use case classes (or case objects) vs extending Enumeration in Scala?
They seem to offer some of the same benefits.
Auriga asked 14/12, 2009 at 4:33
1 Next >
© 2022 - 2024 — McMap. All rights reserved.