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

  • Home
  • SEARCH
  • 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

Hi All I am a newcomer here, I am using the following code from
I'm a newcomer to Rails, and have been following the tutorial on the rails
I'm newcomer in django, and here is question: I have model class: def Client(models.User)
I am new to XML and AJAX and am only a newcomer to Javascript
Relative newcomer to Javascript and a bit stuck with the following so would greatly
I am newcomer in Objective C. I have an object, that creates new thread
I am a newcomer to Silverlight and while I have been following some tutorials
I'm a newcomer to Qt, but I'm trying to implement what basically amounts to
I am a newcomer to Maven, and I was wondering if there was a
As a newcomer to iOS, I found that ARC has thus far really helped

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.