Skip to content

Instantly share code, notes, and snippets.

@jabley
Created October 15, 2009 08:22
Show Gist options
  • Save jabley/210777 to your computer and use it in GitHub Desktop.
Save jabley/210777 to your computer and use it in GitHub Desktop.
$ cat test/test_enumerator.rb
def create_fib()
Enumerator.new { |y|
a = b = 1
loop {
y << a
a, b = b, a + b
}
}
end
def run_fib(i)
fib = create_fib
fib.take i
end
def main
p "not created enumerator yet"
p run_fib 10
p "enumerator should be eligible for GC"
end
main
$ ./bin/jruby --1.9 test/test_enumerator.rb
"not created enumerator yet"
test/test_enumerator.rb:2:in `create_fib': wrong # of arguments(0 for 1) (ArgumentError)
from test/test_enumerator.rb:12:in `run_fib'
from test/test_enumerator.rb:18:in `main'
from test/test_enumerator.rb:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment