[Ruby]swapcaseで文字列の中の大文字と小文字を入れ替える
環境
Windows 10 Home 64bit
ruby 3.1.2p20
書式
文字列.swapcase
swapcaseメソッドは文字列の中の大文字と小文字を入れ替えます。
使用例
target = "Study Skill"
target2 = "ArkGame"
puts target.swapcase
puts target2.swapcase
target = "Study Skill"
target2 = "ArkGame"
puts target.swapcase
puts target2.swapcase
target = "Study Skill" target2 = "ArkGame" puts target.swapcase puts target2.swapcase
実行結果
C:\study\skill\ruby>ruby test.rb
sTUDY sKILL
aRKgAME
C:\study\skill\ruby>ruby test.rb
sTUDY sKILL
aRKgAME
C:\study\skill\ruby>ruby test.rb sTUDY sKILL aRKgAME