Extended maintenance of Ruby 1.9.3 ended on February 23, 2015. Read more
# File irb/ext/history.rb, line 65
def [](idx)
begin
if idx >= 0
@contents.find{|no, val| no == idx}[1]
else
@contents[idx][1]
end
rescue NameError
nil
end
end
# File irb/ext/history.rb, line 84
def inspect
if @contents.empty?
return real_inspect
end
unless (last = @contents.pop)[1].equal?(self)
@contents.push last
last = nil
end
str = @contents.collect{|no, val|
if val.equal?(self)
"#{no} ...self-history..."
else
"#{no} #{val.inspect}"
end
}.join("\n")
if str == ""
str = "Empty."
end
@contents.push last if last
str
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.