I have the following in my ~/.irbrc file:
IRB.conf[:PROMPT][:DEFAULT][:RETURN].prepend ?#
In earlier Ruby versions, this would ensure that each return value was prefixed with a comment symbol rather than just the association token (e.g. #=> rather than =>), which allowed cutting-and-pasting into a REPL without the return values being evaluated. However, after upgrading to Ruby 3.0.0, it seems that newer versions of IRB occasionally wrap the output of long return values, and I'm not sure how to ensure all return values are properly commented out. For example, consider this now-typical output from an unrelated post:
s1 = Suggestion.new :foo, %w[Alice Bob]
#=> #<Suggestion:0x00007f9671154578 @participants=["Alice", "Bob"], @type=:foo>
s2 = Suggestion.new :bar, %w[Charlie Dana]
#=> #<Suggestion:0x00007faed7113900 @participants=:bar, @type=:foo>
Suggestion.all
#=>
[#<Suggestion:0x00007f9671154578 @participants=["Alice", "Bob"], @type=:foo>,
#<Suggestion:0x00007f9671089058
@participants=["Charlie", "Dana"],
@type=:bar>]
Here, the first two lines of code show the return values correctly preceeded by a comment character, but the Array returned by the third line results in the return value following the defined comment characters. The Ruby 3.0.0 IRB module doesn't say anything about this wrapping behavior, or provide any obvious clues about how I can format multi-line return values consistently as comments.
How can I ensure that all lines of the return value in IRB are prefixed with a comment character?