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 9094255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:18:31+00:00 2026-06-16T23:18:31+00:00

What about any case where someone want to apply pattern matching on an entire

  • 0

What about any case where someone want to apply pattern matching on an entire Map object?

Example (though not compiling) would be:

def main(args: Array[String]) {
    val m: Map[String, Int] = Map("a" -> 1, "b" -> 2) //scala.collection.immutable.Map2
    m match {
      case Map2("a",1,"b",2)  => println("matched")   //conceptual code line 
      case _ => println("not matched")
    }
}

What are possible reasons preventing the Map2 definition as a case class?

  • Case class preventing encapsulation of internal fields? (like key1 and value1…)
  • Case class doesn’t apply with generics type parameters?
  • Rare usage of matching an entire Map (making often non-sense)?
  • 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-06-16T23:18:32+00:00Added an answer on June 16, 2026 at 11:18 pm

    One salient reason is that deriving new classes from case classes is deprecated at best, dangerous at worst. In order to allow users (or Scala standard library authors) to derive from these classes, they may not be case classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone point me to any resources about case insensitive comparison in Objective C?
Does anyone know about any API's, IDE's or such that simplifies the development of
Do you know about any open source projects written in XQuery? The larger the
Do you know about any good library wrapping posix and linux functions and structures
When running Silverlight 3.0 in OOB mode, you don't have to worry about any
I am trying to get better about minimizing any unnecessary markup and using optimal
Any ideas about escape analysis in dalvik? Or when and if it's planned to
Any idea about ORA-1555: snapshot too old: rollback segment number I am getting this
Could any body offer me any reason about that? If we do it like
can any body suggest me any idea about how can i compare two fields

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.