This could be written a bit more concisely like:

```
val memoryKeys = Seq(
  "spark.storage.memoryFraction",
  "spark.shuffle.memoryFraction", 
  "spark.shuffle.safetyFraction"),
for (key -> memoryKeys) {
  val value = getDouble(key, 0.5)
  if (value > 1 || value < 0) {
    throw new IllegalArgumentException("$key should be between 0 and (was '$value').")
  }
}
```