Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 537201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:54:07+00:00 2026-05-13T09:54:07+00:00

I am a newcomer to Scala. In 2.7.7, the following code abstract class C

  • 0

I am a newcomer to Scala. In 2.7.7, the following code

abstract class C
case class CC() extends C

trait T

val c1 = CC()
val c2 = new CC() with T
println(c1.hashCode == c2.hashCode,c1 equals c2)

prints

(false,true)

whereas I would have expected

(false,false)

What am I missing? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:54:07+00:00Added an answer on May 13, 2026 at 9:54 am

    Case class equality (particularly in Scala 2.8) equality and hash codes are based upon tuple and/or product equality, and do not currently take the class into account. There was a recent discussion on this matter on the scala-debate mailing list here: http://old.nabble.com/Possible-Collision-Issue-with-Product.hashCode-td27026790.html

    For what it’s worth, here’s what it currently looks like in 2.8:

    Welcome to Scala version 2.8.0.Beta1-RC6 (Java HotSpot(TM) Client VM, Java 1.6.0_16).
    Type in expressions to have them evaluated.
    Type :help for more information.
    
    scala> abstract class C
    defined class C
    
    scala> case class CC() extends C
    defined class CC
    
    scala> trait T
    defined trait T
    
    scala> val c1 = CC()
    c1: CC = CC()
    
    scala> val c2 = new CC() with T
    c2: CC with T = CC()
    
    scala> println(c1.hashCode == c2.hashCode,c1 equals c2)
    (true,true)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a newcomer to ASP, and would like to experiment with it by
For a newcomer to .NET Web Development and programming in general, who chooses C#
According to this question , Scala's type system is Turing complete . What resources
I'm a newcomer to using C++ but have got a general Idea of its
I'm still a newcomer to python, so I hope this question isn't inane. The
I'm a newcomer to SQLAlchemy ORM and I'm struggling to accomplish complex-ish queries on
Alright folks, I am a newcomer to Data Services and LINQ in desperate need
I've started a client/server project at work using Twisted (I'm a newcomer, so not
This is my first post and I'm still a Python and Scipy newcomer, so
I'm building a simple slideshow using jQuery. I have the basics down, but as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.