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 that does the opposite of capitalize
, i.e., uncapitalize
or decapitalize
?
Ruby | String capitalize() Method capitalize is a String class method in Ruby which is used to return a copy of the given string by converting its first character uppercase and the remaining to lowercase.
In Ruby, we use the downcase method to convert a string to lowercase. This method takes no parameters and returns the lowercase of the string that calls it. It returns the original string if no changes are made. Note: This method does not affect the original string.
Symbol#upcase() : upcase() is a Symbol class method which returns the uppercase representation of the symbol object.
There is also:
"coolat_cat".camelize(:lower) # => "coolCat"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With