Skip to content

Commit cd7c6c6

Browse files
tompngnobu
authored andcommitted
[ruby/pp] Simplify range nil check
ruby/pp@3e4b7c03b0 Co-authored-by: Nobuyoshi Nakada <[email protected]>
1 parent 7b51b3c commit cd7c6c6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/pp.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,13 @@ def pretty_print_cycle(q) # :nodoc:
488488

489489
class Range # :nodoc:
490490
def pretty_print(q) # :nodoc:
491-
both_nil = self.begin == nil && self.end == nil
492-
q.pp self.begin if self.begin != nil || both_nil
491+
begin_nil = self.begin == nil
492+
end_nil = self.end == nil
493+
q.pp self.begin if !begin_nil || end_nil
493494
q.breakable ''
494495
q.text(self.exclude_end? ? '...' : '..')
495496
q.breakable ''
496-
q.pp self.end if self.end != nil || both_nil
497+
q.pp self.end if !end_nil || begin_nil
497498
end
498499
end
499500

0 commit comments

Comments
 (0)