diff --git a/core/src/main/ruby/jruby/kernel/enumerator.rb b/core/src/main/ruby/jruby/kernel/enumerator.rb index b5bf63079ac..80ddd73a584 100644 --- a/core/src/main/ruby/jruby/kernel/enumerator.rb +++ b/core/src/main/ruby/jruby/kernel/enumerator.rb @@ -529,6 +529,20 @@ def rewind self end + def inspect + JRuby::Util.safe_recurse(@__enums, self, "inspect") do |state, obj, recur| + if state.nil? + return "#<#{obj.class}: uninitialized>" + end + + if recur + return "#<#{obj.class}: ...>" + end + + return "#<#{obj.class}: #{state.inspect}>" + end + end + private def initialize_copy(other) return self if self.equal?(other)