Note that if you're sure the map contains the key already, you can just use apply (or just treat the map as a function):
commpricemap.get("AU") match {
case Some(prices) if prices.contains("USD") =>
prices("USD")
case _ => 0.0
}
Performance-wise (benchmark to make sure!) if-contains-then-apply will avoid allocations (though it's reasonably likely that your JVM will, if this is a hot code path, optimize the allocation heavy versions into something almost exactly like if-contains-then-apply).
commpricemap.get("AU").flatMap(_.get("USD")).getOrElse(0.0)
...is arguably optimizing for concision, and assuming reasonably aggressive inlining and on-stack-replacement, will get to the same code at runtime in the end.
getOrElse does incur the cost of wrapping the default value in a lambda ("thunk"), even in the defined case, so
commprice.get("AU").flatMap(_.get("USD") match {
case Some(result) => result
case None => defaultfallbackrate
}
avoids that allocation if the expectation is that most of the time there's a price for the commodity in the currency of interest (though again, when it ultimately gets optimized into ifs, the allocation will be delayed).