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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:24:25+00:00 2026-05-25T03:24:25+00:00

They don’t seem to mix that well: abstract class A case class B (var

  • 0

They don’t seem to mix that well:

abstract class A
case class B (var a: Int)(var b: String) extends A
case class C extends A

The following will not work:

B(1)("1") match {
  case B(a)(b) => print("B")
  case C() => print("C")
}

The problem is that pattern matching and curried arguments do not seem to work. Is there a work-around for this?

  • 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-25T03:24:26+00:00Added an answer on May 25, 2026 at 3:24 am

    What’s wrong with this?

    def m(a: A) = a match {
      case b: B => print("B")
      case c: C => print("C")
    }
    

    I’m only asking because you didn’t ask for more functionality than this.

    EDIT

    This could help:

    object Dog {
       def apply(name: String)(size: Int) = new Dog(name)(size)
       def unapply(dog: Dog) = Some(dog.name, dog.size)
    }
    class Dog(val name: String)(var size: Int)
    

    Now you can create dogs either like this:

    new Dog("Snoopy")(10) 
    

    or like this:

    Dog("Snoopy")(10)
    

    But when you pattern match on dogs the constructor pattern is not curried.

    Dog("Snoopy")(10) match {
       case Dog(a, b) => // do sth with a or b
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written regexes for recognizing float and int but they don't seem to
They don't seem to be accessible from ActionView::TestCase
I keep reading about people who are test infected, meaning that they don't just
My hosting service just informed me that they don't have Git installed on any
I have a third party COM component (they don't offer a .Net assy), that
How to generate random integers but making sure that they don't ever repeat? For
I have checked similarly named questions, but they don't answer this use case. Basically,
I'm trying to build an RPM that will install file dependencies if they don't
Sorry I saw similar questions but they don't seem to have some full answers
I've read about WebSockets but they don't seem to be pure sockets, because there

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.