The Artima Developer Community
Sponsored Link

Programming in Scala Forum
subclasses of case classes?

2 replies on 1 page. Most recent reply: Feb 4, 2008 12:49 PM by Javier Diaz Soto

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
David Biesack

Posts: 8
Nickname: djb
Registered: Jan, 2008

subclasses of case classes? Posted: Feb 4, 2008 8:22 AM
Reply to this message Reply
Advertisement
p 210 shows some case classes, including

abstract class Expr
case class Binop(operator: String, left: Expr, right: Expr) extends Expr

I find that I cannot define a subclass of Binop; I get a compiler error:


case class RightAssociativeBinop(operator: String, left: Expr, right: Expr) extends Binop(operator, left,right)

<console>:7: error: error overriding value right in class Binop of type Expr;
value right needs `override' modifier
case class RightAssociativeBinop(operator: String, left: Expr, right: Expr) extends Binop(operator, left,right)
^


Can someone explain what is wrong?

thanks


Javier Diaz Soto

Posts: 29
Nickname: javierbds
Registered: Sep, 2005

Re: subclasses of case classes? Posted: Feb 4, 2008 12:45 PM
Reply to this message Reply
Take a look at the change log of Scala on the web, case class inheritance will be supported in the next upgrade (i guess that's it).

Javier Diaz Soto

Posts: 29
Nickname: javierbds
Registered: Sep, 2005

Re: subclasses of case classes? Posted: Feb 4, 2008 12:49 PM
Reply to this message Reply
http://www.scala-lang.org/docu/changelog.html

Flat View: This topic has 2 replies on 1 page
Topic: indexed view on case classes Previous Topic   Next Topic Topic: Unified errata

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use