Ruby on Rails uncapitalize first letter

前端 未结 10 1469
感动是毒
感动是毒 2021-02-03 19:48

I\'m running Rails 2.3.2.

How do I convert \"Cool\" to \"cool\"? I know \"Cool\".downcase works, but is there a Ruby/Rails method

10条回答
  •  北恋
    北恋 (楼主)
    2021-02-03 20:31

    There is an inverse of capitalize called swapcase:

    "Cool Cat".swapcase   #=> "cOOL cAT"
    

提交回复
热议问题