Skip to content

Instantly share code, notes, and snippets.

@kijuky
Created August 14, 2011 10:05
Show Gist options
  • Save kijuky/1144761 to your computer and use it in GitHub Desktop.
Save kijuky/1144761 to your computer and use it in GitHub Desktop.
ReturnFromAnonymousFunction
object ReturnFromAnonymousFunction {
def main(args: Array[String]) {
println(hoge())
}
def hoge: () => Seq[Int] = {
() =>
(1 to 10).map {
i =>
if(i < 5)
return () => Nil
i
}
}
}
// > scalac ReturnFromAnonymousFunction.scala
// > scala ReturnFromAnonymousFunction
// scala.runtime.NonLocalReturnControl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment