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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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 }

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.