Last active
August 29, 2015 14:22
-
-
Save ryandavidhartman/9c0bb66529f584e2eea2 to your computer and use it in GitHub Desktop.
try_example8
This file contains hidden or 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
object Program { | |
def apply(): Program = new Program() | |
} | |
trait Program { | |
def collectData(): Try[List[Data]] = { | |
val data = dataGetter() | |
if(data.length < 1) | |
throw new DataException("Data Collection Fails") | |
else | |
data | |
} | |
val results: Int = { | |
val program = Program() | |
for { | |
data <- program.collectData() | |
results <- data.sumBy(i => i.value | |
} yield results | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment