![]() |
In this article, we will discuss how to convert a string to lower or upper case in Ruby. We can convert a string to lower or upper case using built-in methods provided in the Ruby language. Table of Content Using DowncaseThe Syntax:
In the below example, the string is converted to lowercase using the
Output Original String: Geeks for Geeks String in Lowercase: geeks for geeks Using UpcaseThe upcase method is used to convert the string to uppercase Syntax:
In the below example,the string is converted to uppercase using the uocase method and store the result in the variable and at last output both the original and uppercase string.
Output Original String: Geeks For Geeks String in Uppercase: GEEKS FOR GEEKS Using CapitalizeCapitalize is used to capitalize the first character of the string while converting the rest to lowercase. Syntax:
In the below example,the string first letter is capitalized and the rest to lowercase. After which we store the result in the variable and output the both the original and capitalized string.
Output Original String: GEEKS FOR GEEKS Capitalized String: Geeks for geeks |
Reffered: https://www.geeksforgeeks.org
Ruby |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |