Skip to content

Instantly share code, notes, and snippets.

@ryandavidhartman
Last active August 29, 2015 14:22
Show Gist options
  • Save ryandavidhartman/73925f14fbf5a46af397 to your computer and use it in GitHub Desktop.
Save ryandavidhartman/73925f14fbf5a46af397 to your computer and use it in GitHub Desktop.
Example 1 of Scala Try syntax
object Program {
def apply(): Program = new Program()
}
trait Program {
def collectData(): List[Data] = { some code, returning a list of Data items }
def processData(data: List[Data]): Int = { data.sumBy(i => i.value }
def Run(): Int = {
val program = Program()
val data = program.collectData()
program.processResults(data)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment