OneBite.Dev - Coding blog in a bite size

convert a string to uppercase in Ruby

Code snippet on how to convert a string to uppercase in Ruby

  str = "Hello World"
  str.upcase # => "HELLO WORLD"

This code uses the upcase method to convert a string to uppercase. The string “Hello World” is stored in the variable str. The upcase method is then called on the string, which returns the same string in uppercase. This is then stored in the same variable str. So, after running this code, str will now contain the uppercase version of the original string.

ruby