How to customize the return output of Ruby commands in Pry
-
28-05-2021 - |
문제
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?
해결책
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.
제휴하지 않습니다 StackOverflow