Created
November 3, 2011 15:38
-
-
Save Arcnor/1336800 to your computer and use it in GitHub Desktop.
Bad addProperty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def addProperty(property : String, value : AnyRef) { | |
val propName = property.trim().toUpperCase(); | |
var list = if (!(_props contains propName)) _props(propName) else { | |
var list = new ListBuffer[AnyRef](); | |
_props.put(propName, list); | |
list; | |
} | |
value -> list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var _props: Map[String, List[AnyVal]] = Map.empty()
def addProperty(property: String, value: AnyRef) {
val propName = property.trim.toUpperCase // don't need the () or ; here
val list = _props get property match {
case None => Nil // no item? return the empty list
case Some(items) => items // some items? return them
}
_props += (property -> value::list)
}