String Basics and Methods
Common string operations.
What Is a String?
A String is a sequence of characters. In Ruby you create one with single or double quotes.
'hello'is a single-quoted string"hello"is a double-quoted string
Strings are everywhere: names, messages, file contents and more.
greeting = "Hello, Ruby!"
puts greetingString Length
Use length (or its alias size) to count the characters in a string.
word = "banana"
puts word.length
puts word.sizeAll lessons in this course
- String Basics and Methods
- Interpolation and Formatting
- Searching and Replacing
- Splitting and Joining