Created
August 21, 2020 16:11
-
-
Save spytheman/00a65699d8884712f1740353d6dada91 to your computer and use it in GitHub Desktop.
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
| fn new_counter_generator() fn () int { | |
| mut count := -1 | |
| return fn () int { | |
| count = count + 1 | |
| return count | |
| } | |
| } | |
| fn main() { | |
| a := new_counter_generator() | |
| b := new_counter_generator() | |
| println( a() ) | |
| println( a() ) | |
| println( a() ) | |
| println( a() ) | |
| println( b() ) | |
| println( b() ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment