Project

General

Profile

Bug #19769

Updated by alexandre (alexandre borderes) almost 2 years ago

Hi, 

 I noticed a possible unexpected behavior in String#tr. 
 Is that intentional? 

 ``` ruby 
 'ABC'.tr 'A-AB', 'XY'     # => "YYC" 
 ``` 

 I would expect the same result as: 
 ``` ruby 
 'ABC'.tr 'AB', 'XY'       # => "XYC" 
 ``` 

 The tr utility does exactly that: 
 ``` shell 
 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) 

Back