mysema/scalagen — Issue #30: Simplify certain for / if / return patterns
Author: timowest
Created: 2012-01-20 20:21:25+00:00
State: open

def getFormat(contentType: String, defaultFormat: Format): Format = {
for (format <- values if format.mimetype == contentType) {
return format
}
defaultFormat
}

could be expressed as

def getFormat(contentType: String, defaultFormat: Format): Format = {
values.find(_.mimetype == contenType).getOrElse(defaultFormat)
}