Case conversion changes the letter case of a string. Ruby provides methods for raising, lowering, swapping, and capitalizing case; each has a receiver-modifying bang equivalent, including capitalize!. section 8.1.5
The principal transformations are:
- upcase converts "David A. Black" to "DAVID A. BLACK". section 8.1.5
- downcase converts it to "david a. black". section 8.1.5
- swapcase reverses the case of each letter, producing "dAVID a. bLACK". section 8.1.5
- capitalize transforms "david" into "David". section 8.1.5
>> string = "David A. Black"
=> "David A. Black"
>> string.upcase
=> "DAVID A. BLACK"
>> string.downcase
=> "david a. black"
>> string.swapcase
=> "dAVID a. bLACK"
Compare upcase, downcase, and swapcase directly in an irb-sized example. section 8.1.5
>> string = "david"
=> "david"
>> string.capitalize
=> "David"
See capitalization applied to a lowercase string. section 8.1.5
