Project

General

Profile

Actions

Bug #1953

closed

empty range in String#tr causes unexpected behavior

Added by mame (Yusuke Endoh) over 14 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2dev (2009-08-18 trunk 24578) [i686-linux
Backport:
[ruby-dev:39108]

Description

=begin
Are these intentional?

"ABC".tr("ABC", "pq-a") #=> "pqq"
"ABC".tr("ABC", "pq-ar") #=> "prr"
"ABC".tr("ABC", "pq-ars") #=> "prs"
"ABC".tr("ABC", "pq-arst") #=> "prs"

I expect that an exception is raised or that "p-a" equals to
"ponmlk...cba" (descending order).

For reference, empty range is rejected in Perl:

$ perl -e '"A" =~ tr/A/q-a/;'
Invalid range "q-a" in transliteration operator at -e line 1.

--
Yusuke ENDOH
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0