score:65
Accepted answer
A case class
implements the equals
method for you while a class
does not. Hence, when you compare two objects implemented as a class
, instead of case class
, what you're comparing is the memory address of the objects.
It's really the same issues as when you have to deal with equality in Java. See this Artima blog post about writing equals
in Java (and Scala) written by Bill Venners, Martin Odersky, and Lex Spoon.
Source: stackoverflow.com
Related Query
- Scala class and case class == comparison
- Scala 2.10, its impact on JSON libraries and case class validation/creation
- Understanding Case class and Traits in Scala
- Scala wont pattern match with java.lang.String and Case Class
- Scala getting field and type of field of a case class
- Problem with bounded type parameterised case class and default args in Scala
- @JsonIgnore serialising Scala case class property using Jackon and Json4s
- Scala case class copy-method difference between 2.9 and 2.10
- Best way to perform case insensitive comparison for Scala case class
- == for case class and "non-case" class in Scala
- Scala type inference not working with generic case class and lambda
- Scala case class arity limit and jvm 254 limit
- Scala compiler says my method is recursive in case when implicits and anonymous class is used
- Why and how to migrate case class to extractor in Scala
- Scala compare case class and get changed fields
- Passing case class between Scala and Flex using BlazeDS
- Scala traits using generics and case class methods
- scala function to compare fields of case class and collect the diff
- Playframework, scala case class and property not found
- How to get Scala case class fields and values as (String, String) with Shapeless or Macro
- Scala Play framework controller, converting between JSON and case class
- Scala reflection: how do I define a case class at runtime and then reference to it?
- How to convert JSON into Scala class (NOT Case class), and then populate set of case classes from that big class
- Scala problems with slick 2, when case class and object name are same
- Scala ambiguous case class generated and companion apply method
- How to get list of fields and subfields of a Scala case class
- Scala BigDecimal in a case class and forcing a MathContext
- Scala case class and companion object can't override apply with diff signature
- scala : case class and how to organize
- Scala And Avro: Convert the case class to avro record
More Query from same tag
- Spark LDA with scala and Java
- Row count broken up by a focal value
- Upper type bound allowing subtypes but not the parent type
- Surprisingly slow of mutable.array.drop
- Scala logger in config cannot be loaded
- Scala - Typeclass example. How to explain the benefits?
- Decoding JSON values in circe where the key is not known at compile time
- RDD accessing values in another RDD
- Versioning does not increment automatically
- Does Scala have an API method that converts a Seq[Option[T]] to Seq[T]?
- Can't get path-dependent types to work in scala enumerations
- missing Cats Functor[Future] instance
- Scala working with very large list
- sbt-assembly not including dependencies
- Filter matching and non-matching elements into different halves of a tuple
- Is it possible for Scala to infer types for Generic types passed into a dependent class?
- SBT project not mounted to Docker container using docker-compose
- ScalaJS: How to convert String to String?
- why arguments of a function cannot be declared val or var
- Assert order of messages received using Akka TestProbe
- Does gatling reported response times include the response time from a hosted redis feeder?
- how to convert seq[row] to a dataframe in scala
- java.lang.OutOfMemoryError: Java heap space in spark application
- How to filter out records from a join of two dataframe d1 and d2 where for all column in d1 =!= all corresponding column in d2
- Spark SQL + Cassandra: bad performance
- How to I write a Specs2 matcher for "a,b,c".containsAllOf("b","a")?
- How to achieve true application modularity using Akka in OSGi bundles?
- How to remove all characters that start with "_" from a spark string column
- Java Play 2.3.8: DataSource user is null? bindFromRequest() does not work properly
- Executing a task dependency for test failure in SBT