Skip to content

Commit

Permalink
[ruby/irb] Replace METHOD_IS_A with ===
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 authored and matzbot committed Mar 13, 2023
1 parent 1a8a24a commit 309ff92
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/irb/color_printer.rb
Expand Up @@ -4,7 +4,6 @@

module IRB
class ColorPrinter < ::PP
METHOD_IS_A = Object.instance_method(:is_a?)
METHOD_RESPOND_TO = Object.instance_method(:respond_to?)
METHOD_INSPECT = Object.instance_method(:inspect)

Expand All @@ -26,7 +25,7 @@ def screen_width
end

def pp(obj)
if METHOD_IS_A.bind(obj).call(String)
if String === obj
# Avoid calling Ruby 2.4+ String#pretty_print that splits a string by "\n"
text(obj.inspect)
elsif !METHOD_RESPOND_TO.bind(obj).call(:inspect)
Expand Down

0 comments on commit 309ff92

Please sign in to comment.