To convert a string to lowercase in Ruby, you can use the downcase
method.
In this example,
str
with the value "Hello World"
.downcase
on str
to convert it to lowercase.str
.str = 'Hello World'
lowercase_str = str.downcase
puts lowercase_str
hello world
In this example,
str
with the value "Ruby Programming"
.downcase
on str
to convert it to lowercase.str
.str = 'Ruby Programming'
lowercase_str = str.downcase
puts lowercase_str
ruby programming
In this tutorial, we learned How to convert String to Lowercase in Ruby language with well detailed examples.