Kirill Zhuravlov Kirill Zhuravlov - 13 days ago 6
Ruby Question

How to lowercase only first character in string ruby

How can I lowercase only first character in string with ruby? All existing methods I found doesn't make a job.

input "Hello World"
output "hello World"

Answer

One way:

str = "Hello World"
str[0] = str[0].downcase
str #=> "hello World"
Comments