John Bachir
John Bachir

Reputation: 22751

What determines what is returned/shown by irb?

How does irb decide how to represent an object that is returned from a statement?

> "foo"
=> "foo"
> 2
=> 2

I thought it was the equivalent of print object.inspect or some such thing, but nothing I try returns the same output.

Upvotes: 2

Views: 76

Answers (1)

Matheus Moreira
Matheus Moreira

Reputation: 17030

Well, irb implements a REPL. It pretty much does this behind scenes:

loop do
  '> '.display
  input = gets.chomp
  value = eval input
  puts " => #{value.inspect}"
end

Upvotes: 4

Related Questions