Skip to content

Instantly share code, notes, and snippets.

@djsun
Created February 5, 2010 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djsun/296063 to your computer and use it in GitHub Desktop.
Save djsun/296063 to your computer and use it in GitHub Desktop.
$ ruby --version
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]
$ gem list | grep json
json (1.2.0)
json_pure (1.2.0)
$ gem list | grep activesupport
activesupport (2.3.5)
# add this line before requiring 'json' or 'active_support':
require 'generator.rb'
# I figured this out by reading:
# https://rails.lighthouseapp.com/projects/8994/tickets/2942-enumerableenumeratornext-causes-stack-level-too-deep-since-activesupport-233
require 'rubygems'
require 'ruby-debug'
require 'json'
class Stream
def initialize
@data = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
@iterator = @data.each
end
def fetch
@iterator.next
end
end
def main
data = Stream.new
debugger
loop do
x = data.fetch
puts x
end
end
main
$ ruby fail_1.rb
fail_1.rb:19
loop do
(rdb:1) s
fail_1.rb:20
x = data.fetch
(rdb:1) s
fail_1.rb:12
@iterator.next
(rdb:1) s
fail_1.rb:12:in `next': stack level too deep (SystemStackError)
from fail_1.rb:12:in `fetch'
from fail_1.rb:20:in `main'
from fail_1.rb:19:in `loop'
from fail_1.rb:19:in `main'
from fail_1.rb:25
require 'rubygems'
require 'ruby-debug'
require 'active_support'
class Stream
def initialize
@data = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
@iterator = @data.each
end
def fetch
@iterator.next
end
end
def main
data = Stream.new
debugger
loop do
x = data.fetch
puts x
end
end
main
brooklyn:iter djsun$ ruby fail_2.rb
fail_2.rb:19
loop do
(rdb:1) s
fail_2.rb:20
x = data.fetch
(rdb:1) s
fail_2.rb:12
@iterator.next
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:84
result = blank_slate_method_added(name)
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:85
return result if self != Object
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:85
return result if self != Object
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:84
result = blank_slate_method_added(name)
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:85
return result if self != Object
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:85
return result if self != Object
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:84
result = blank_slate_method_added(name)
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:85
return result if self != Object
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:85
return result if self != Object
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:84
result = blank_slate_method_added(name)
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:85
return result if self != Object
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:85
return result if self != Object
(rdb:1) s
/Users/djsun/.gem/ruby/1.8/gems/builder-2.1.2/lib/blankslate.rb:84
result = blank_slate_method_added(name)
(rdb:1)
...
class Stream
def initialize
@data = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
@iterator = @data.each
end
def fetch
@iterator.next
end
end
def main
data = Stream.new
loop do
puts data.fetch
end
end
main
1
1
2
3
5
8
13
21
34
55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment