How to output any data using the $stdout method

Overview

In Ruby, $stdout represents the current standard output and a global variable. It means we can also use it to output data.

Syntax

$stdout << data
Syntax for $stdout in Ruby

Return value

This method returns the data printed to the console.

Code example

Let's look at the code below:

# create a variable
name = "Okwudili"
$stdout << "hello " << name
$stdout << "\nWelcome to Edpresso\n"

Free Resources