Class definition thinks setting a variable is a Unit?
- by DeLongey
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?