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

后端 未结 11 937
梦如初夏
梦如初夏 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:22

    You can find out all the methods available on a String by opening irb and running:

    "MyString".methods.sort
    

    And for a list of the methods available for strings in particular:

    "MyString".own_methods.sort
    

    I use this to find out new and interesting things about objects which I might not otherwise have known existed.

提交回复
热议问题