[ruby/pp] Simplify range nil check

https://github.com/ruby/pp/commit/3e4b7c03b0

Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
This commit is contained in:
tomoya ishida 2024-11-13 23:18:41 +09:00 committed by git
parent 7b51b3c75b
commit cd7c6c66b4

View File

@ -488,12 +488,13 @@ end if defined?(Data.define)
class Range # :nodoc:
def pretty_print(q) # :nodoc:
both_nil = self.begin == nil && self.end == nil
q.pp self.begin if self.begin != nil || both_nil
begin_nil = self.begin == nil
end_nil = self.end == nil
q.pp self.begin if !begin_nil || end_nil
q.breakable ''
q.text(self.exclude_end? ? '...' : '..')
q.breakable ''
q.pp self.end if self.end != nil || both_nil
q.pp self.end if !end_nil || begin_nil
end
end