ruby/doc/string/swapcase.rdoc
2025-10-27 21:19:42 -04:00

20 lines
595 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Returns a string containing the characters in +self+, with cases reversed:
- Each uppercase character is downcased.
- Each lowercase character is upcased.
Examples:
'Hello World!'.swapcase # => "hELLO wORLD!"
'тест'.swapcase # => "ТЕСТ"
Some characters (and even character sets) do not have casing:
'12345'.swapcase # => "12345"
'こんにちは'.swapcase # => "こんにちは"
The casing may be affected by the given +mapping+;
see {Case Mapping}[rdoc-ref:case_mapping.rdoc].
Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].