Actions
Bug #19769
closedRange of size 1 in String#tr causes unexpected behavior
    Bug #19769:
    Range of size 1 in String#tr causes unexpected behavior
  
Description
Hi,
I noticed a possible unexpected behavior in String#tr.
Is that intentional?
'ABC'.tr 'A-AB', 'XY'   # => "YYC"
I would expect the same result as:
'ABC'.tr 'AB', 'XY'     # => "XYC"
The tr utility does exactly that:
echo ABC | tr A-AB XY   # => "XYC"
The letter 'A' is interpreted 2 times in that case, shifting by 1 all the replacement string.
(I found this related https://bugs.ruby-lang.org/issues/1953)
        
          
          Updated by alexandre (alexandre borderes) over 2 years ago
          
          
        
        
      
      - Description updated (diff)
 
I created a PR https://github.com/ruby/ruby/pull/8080
        
          
          Updated by Anonymous over 2 years ago
          
          
        
        
      
      - Status changed from Open to Closed
 
Applied in changeset git|e5825de7c9f07e4f7bd2b83ce8973e19a4652916.
[Bug #19769] Fix range of size 1 in String#tr
Actions