Only parameters in the first parameter section are considered for equality and hashing.
scala> case class Foo(a: Int)(b: Int)
defined class Foo
scala> Foo(0)(0) == Foo(0)(1)
res0: Boolean = true
scala> Seq(0, 1).map(Foo(0)(_).hashCode)
res1: Seq[Int] = List(-1669410282, -1669410282)
UPDATE
To expose b
as a field:
scala> case class Foo(a: Int)(val b: Int)
defined class Foo
scala> Foo(0)(1).b
res3: Int = 1
Related Contents:
- Why doesn’t Scala have static members inside a class?
- Difference between object and class in Scala
- How to properly document S4 class slots using Roxygen2?
- Swift: Test class type in switch statement
- What does `:_*` (colon underscore star) do in Scala?
- ‘POCO’ definition
- Scala equivalent of Java java.lang.Class Object
- Using comparison operators in Scala’s pattern matching system
- Unable to create Scala class on IntelliJ
- CKEditor automatically strips classes from div
- How to update a mongo record using Rogue with MongoCaseClassField when case class contains a scala Enumeration
- How is pattern matching in Scala implemented at the bytecode level?
- Class constructor type in typescript?
- Classes vs. Functions [closed]
- What are public, private and protected in object oriented programming?
- Tools for creating Class Diagrams [closed]
- class overrule when two classes assigned to one div
- Why can’t Swift initializers call convenience initializers on their superclass?
- Scala multiple type pattern matching
- How do I declare a model class in my Angular 2 component using TypeScript?
- How to pattern match multiple values in Scala?
- Types and classes of variables
- How to override apply in a case class companion
- What’s the difference between a protocol extended from AnyObject and a class-only protocol?
- Pattern Matching `@` Symbol
- Catching multiple exceptions at once in Scala
- How should I deal with object hierarchies in a RESTful API?
- How can I easily get a Scala case class’s name?
- Scala’s sealed abstract vs abstract class
- constructor with parameters in UML class diagram
- Is it bad practice to have my getter method change the stored value?
- class in R: S3 vs S4
- Scala pattern matching on sequences other than Lists
- Pattern matching with conjunctions (PatternA AND PatternB)
- Relationship between a TypeScript class and an interface with the same name
- Can we use match to check the type of a class
- Dynamic class in Angular.js
- Implementing an indexer in a class in TypeScript
- Use of Custom Data Types in VBA
- Is there a cleaner way to pattern-match in Scala anonymous functions?
- The argument types of an anonymous function must be fully known. (SLS 8.5)
- How to pattern match large Scala case classes?
- What exactly is a Class Factory?
- List of class’s properties in swift
- How to tell if an object is an instance of a class
- How do I match multiple arguments?
- What is the difference between unapply and unapplySeq?
- What is scala’s experimental virtual pattern matcher?
- Counting instances of a class?
- How can I pattern match on a range in Scala?