Skip to content

Instantly share code, notes, and snippets.

Created December 30, 2018 11:54
What would you like to do?
class JazzBandSpec extends FlatSpec with Matchers{
"Jazz band closure " should " create a musician closure with access to band set list" in {
val setList = List("Donna Lee", "Dig")
val jazzBandFunctionThatCreatesMusician: List[String] => () => List[String]
= JazzBand.jazzBandThatCreatesMusician
val musicianFunctionThatCanGetBandSetList: () => List[String]
= jazzBandFunctionThatCreatesMusician(setList)
musicianFunctionThatCanGetBandSetList() should be (setList)
//Re-writing the above in a more idiomatic and simplified way
JazzBand.jazzBandThatCreatesMusician(setList)() should be (setList)
package object JazzBand {
def jazzBandThatCreatesMusician(setList: List[String])
= () => setList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment