Ruby Monstas


Strings

Strings

Strings of characters

For example the 5 characters
H
,
e
,
l
,
l
,
o
result in the string
Hello

Strings in Ruby

We can define a String using quotes:

  • Single quotes, e.g.
    'Hello'
  • or double quotes, e.g.
    "Hello"

To Ruby it doesn't matter which quotes we use!

Usage of Strings

Strings are used whenever we're dealing with text in our programs

For example, we want to know the user's name and password for logging them in. Both name and password will be Strings in our program!

Strings are probably the most often used data type in any programming language!

Additional Resources

Ruby For Beginners: Strings

What questions do you have?