foo is an array of objects, bar is an attribute of this object.
(rdb:1) foo.bar.map{|v| bar.v } ["a", "b", "c", "d", "e", "f"] (rdb:1) foo.bar.each{|v| p bar.v } [massive outpouring of object attributes]
Because the result is eachdefined as a renamed Enumerable.
each
If you want to use eachin irb and not boot with output, then:
foo.bar.each{|v| p bar.v }; nil
#eachwill return its receiver, and then irb decides to print it, since irb is a REPL.
#each
You can simply click .any?at the end of the expression:
.any?
(rdb:1) foo.bar.each{|v| p bar.v }.any? # output from only the #p call => true
, IRB . , ; nil .
; nil
inspect bars, .
inspect
bars
class Bar def inspect "tl;dr" end end