Search code examples
ruby-on-railsrubyconsoleirb

Stop rails console from printing out the object at the end of a loop


If I, say, loop through all the instances of a given model and output something from each, at the end, irb will still print the entire object.

If the object ends up taking hundreds of lines, it'll be a long way up before I see what I was actually looking for. Is there a way to disable this in the rails console?


Solution

  • If you don't want to disable the echo in general you could also call multiple expressions in one command line. Only the last expression's output will be displayed.

    big_result(input); 0