4

I was able to customize the prompt for Pry with the Pry.config.prompt setting in ~/.pryrc in order to make Pry simpler for kids. Now I want to get rid of the return output:

Enter Ruby code> puts 'hello'
hello
=> nil
Enter Ruby code> 

The => nil is confusing for a kid just learning to program. Can I suppress the return value output in Pry?

at.
  • 50,922
  • 104
  • 292
  • 461

1 Answers1

5

There are a few ways to do it. Either add ; to the end of each line or replace the default Pry.config.print with a proc of your own. For example, adding something like

Pry.config.print = Proc.new { |output, value| }

to your ~/.pryrc should do the trick.

sluukkonen
  • 2,566
  • 1
  • 19
  • 12
  • 2
    Perfect!! And actually I realized I do want the return value to be displayed if it's not nil... so I added this to `~/.pryrc`: `Pry.config.print = Proc.new { |output, value| output.puts "=> #{value.inspect}" unless value == nil }` – at. Mar 30 '12 at 19:56