D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
String
/
Filename :
tr-i.ri
back
Copy
U:RDoc::AnyMethod[iI"tr:ETI"String#tr;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"QReturns a copy of +self+ with each character specified by string +selector+ ;TI"Itranslated to the corresponding character in string +replacements+. ;TI"(The correspondence is _positional_:;To:RDoc::Markup::BlankLine o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"DEach occurrence of the first character specified by +selector+ ;TI"<is translated to the first character in +replacements+.;To;;0; [o; ; [I"EEach occurrence of the second character specified by +selector+ ;TI"=is translated to the second character in +replacements+.;To;;0; [o; ; [I"And so on.;T@o; ; [I" Example:;T@o:RDoc::Markup::Verbatim; [I"('hello'.tr('el', 'ip') #=> "hippo" ;T:@format0o; ; [I"3If +replacements+ is shorter than +selector+, ;TI"9it is implicitly padded with its own last character:;T@o;; [I"-'hello'.tr('aeiou', '-') # => "h-ll-" ;TI"-'hello'.tr('aeiou', 'AA-') # => "hAll-" ;T;0o; ; [I"OArguments +selector+ and +replacements+ must be valid character selectors ;TI"E(see {Character Selectors}[rdoc-ref:character_selectors.rdoc]), ;TI"Rand may use any of its valid forms, including negation, ranges, and escaping:;T@o;; [ I"# Negation. ;TI",'hello'.tr('^aeiou', '-') # => "-e--o" ;TI"# Ranges. ;TI"''ibm'.tr('b-z', 'a-z') # => "hal" ;TI"# Escapes. ;TI"O'hel^lo'.tr('\^aeiou', '-') # => "h-l-l-" # Escaped leading caret. ;TI"Q'i-b-m'.tr('b\-z', 'a-z') # => "ibabm" # Escaped embedded hyphen. ;TI"J'foo\\bar'.tr('ab\\', 'XYZ') # => "fooZYXr" # Escaped backslash.;T;0: @fileI" string.c;T:0@omit_headings_from_table_of_contents_below0I".tr(selector, replacements) -> new_string ;T0[ I" (p1, p2);T@AFI"String;TcRDoc::NormalClass00