def someFunc() = { var someLocalVariable = 0; val closure1 = {()=> someLocalVariable += 5; someLocalVariable; }; val closure2 = {()=> someLocalVariable -= 2; someLocalVariable; }; (closure1, closure2); } val closures = someFunc(); println(closures._1()); println(closures._1()); println(closures._2());
Thursday, September 27, 2012
Closures
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment