Ruby-on-rails – Why is Ary.each to dump all content of the object?

foo is an array of objects, and bar is an attribute of the object.

(rdb:1) foo .bar.map{|v| bar.v }
["a", "b", "c", "d", "e", "f"]

< br />(rdb:1) foo.bar.each{|v| p bar.v }
[massive outpouring of object attributes]

Because the result of each is defined as an Enumerable object to be iterated.

If you want to use each in irb instead of overwhelming the output , Then:

foo.bar.each{|v| p bar.v }; nil

foo is An array of objects, bar is an attribute of the object.

(rdb:1) foo.bar.map{|v| bar.v }< br />["a", "b", "c", "d", "e", "f"]


(rdb:1) foo.bar.each {|v| p bar.v }
[massive outpouring of object attributes]

Because the result of each is defined as the Enumerable to be iterated Object.

If you want to use each in irb instead of flooding the output, then:

foo.bar.each{|v | p bar.v }; nil

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3313 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.