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

 

In Ruby, you can easily convert a string to lowercase or uppercase using the downcase and upcase methods, respectively. Here's how you can do it with examples:

  1. Converting to lowercase using the downcase method:
ruby
original_string = "Hello, World!" lowercase_string = original_string.downcase puts "Original: #{original_string}" puts "Lowercase: #{lowercase_string}"

Comments