Class definition thinks setting a variable is a Unit?
Posted
by
DeLongey
on Stack Overflow
See other posts from Stack Overflow
or by DeLongey
Published on 2012-06-07T22:22:38Z
Indexed on
2012/06/07
22:40 UTC
Read the original article
Hit count: 187
scala
Writing out a Scala class and problem here is that the compiler thinks that the code is a unit not returning the proper value. It's a method used to set a property in the class:
def setObject(`object`:StripeObject):StripeObject = {
this.`object` = `object`
}
The error is: type mismatch; found : Unit required: com.stripe.StripeObject
The full class is:
case class EventData(var previousAttributes: HashMap[String,Object], var `object`:StripeObject) extends StripeObject {
def getPreviousAttributes = {
previousAttributes
}
def setPreviousAttributes(previousAttributes: HashMap[String, Object]) = {
this.previousAttributes = previousAttributes
}
def getObject = {
`object`
}
def setObject(`object`:StripeObject):StripeObject = {
this.`object` = `object`
}
}
How do I make sure it doesn't return a Unit?
© Stack Overflow or respective owner