How to convert a string to lower or upper case in Ruby

后端 未结 11 938
梦如初夏
梦如初夏 2020-12-07 07:00

How do I take a string and convert it to lower or upper case in Ruby?

11条回答
  •  一整个雨季
    2020-12-07 07:15

    The .swapcase method transforms the uppercase latters in a string to lowercase and the lowercase letters to uppercase.

    'TESTING'.swapcase #=> testing
    'testing'.swapcase #=> TESTING
    

提交回复
热议问题