Once I do a rails c and get some rows form the db like so:
users = User.find(:all,:conditions => ["some conds"])
then users has say 20 results
If I then do a
users.each do |u|
puts u.name if u.gender == 'male'
end
then after printing all the male names, the console again outputs all the content of the users object. I don’t need to see it again. How can I suppress it? All I am interested in is the output of puts
That’s how console works. You enter expression, it prints its value.
Value of this code is
usersobject itself and it is correctly printed. What you print withputsis a side effect.You can still suppress printing full contents of
usersby changing return value of this expression. For example, like this: