Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
irb 如何决定如何表示从语句返回的对象?
> “富” => “富” > 2 => 2
我认为它是等价的print object.inspect或类似的东西,但我没有尝试返回相同的输出。
print object.inspect
好吧,irb实现一个REPL。它在幕后几乎是这样做的:
irb
loop do '> '.display input = gets.chomp value = eval input puts " => #{value.inspect}" end