Ruby - String String

Introduction

Consider the following code

Demo

puts "Hello, world!"

Result

A string is a collection of textual characters.

It may include digits, letters, whitespace, and symbols of any length.

All strings in Ruby are objects of the String class:

Demo

puts "Hello, world!".class

Result

Strings can be included in operations, added to, and compared against.

You can assign strings to variables:

Demo

x = "Test" 
y = "String" 
puts "Success!" if x + y == "TestString"

Result

Related Topics