test = "The Rizzler
Rizzly Bear
The Boy Who Cried Rizz
Abraham Rizzcoln
Adolf Rizzler
Rizzy Neutron
A Degree In Quantum Rizzics
Barack Rizzbama
Need a Rizztraining Order
Anakin Rizzwalker
Rizzard of Oz
Lord of the Rizz
Performed a Rizzerruction
Rizzosaurus Rex
From the Village Hidden in the Rizz Offering
Rizztitution and Rizzarations
Glenn Rizzmire
Rizz Khalifa
Martin Luther Rizz
Kamala Harizz
Rizzy Hendrix / Jimi Hendrizz
Rizzilicious
Rizziliguous
Rizziologist
Rizzillionaire
Rizz Ranger
The Rizz Reaper
Leader of the Rizzistance
Chrizz Brown
Rizzolph the Rizz-nosed Deer
Wolverizz
Head Coach of the Memphis Rizzlies
Prisoner of Rizzkaban
Rizzaholic
Rizza Parks
Rizz Hemsworth
Albert Rizzenstein
Playing Rizzident evil
Mike Rizzowski
Franklin D Rizzevelt
Queen Erizzabeth
Kyle Rizzenhouse
Walt Rizzney
Signed the Declaration of Rizzdependence
From the State of Rizzouri
Rizz Al Ghul
Corona Virizz
Rizztafarian
Rizzie Smalls
R(izz) Kelly
Rizzil War Veteran
Rizz and Morty
Geralt of Rizzia Alvin and the Rizzmunks
Otto von Rizzmark
The Last Rizzort
Got a Ticket for the Polar Rizzpress / Exprizz
Artirizzal Intelligence
Natural Rizzaster, First Rizzponder
Member of the Nation of Rizzlam
Crizztiano Rizzaldo
Rizzaldinho
The Grand Rizzard
Ghost of Rizzmas Past
13 Rizzons Why
Ate the Rizz Rizz Fruit
One of the Three Rizzmirals
7 Rizzlords of the Sea
Qualified for Rizzlemania
Sent to Prizzon
George Rizzington
Theodore Rizzevelt
The Little Boy from Rizzario
Plays for Real Madrizz
The Last Rizzbender
Found the Derizzative of the Function
Lando Cal-rizz-ian
Aurizztic / Diagnosed with Aurizzm
Jack the Rizzer
Grew up in Rizzadelphia
Rizzatron
Dwayne the Rizz Johnson
Master of the Rizztic Arts
Osama Rizz Laden
Frosty the Rizzman
The Rizziah
Fell Into an Economic Rizzession
Rizzas in Paris
Chuck Norizz
Sir Rizz-a-lot
Rules the Rizzantine Empire
Rizzioactive
Cooking Rizzatouille
Forizz Gump
Diet Involves Blue Rizzberies
The Nightmare Before Rizzmas
Rizzeree
Damian Rizzard
In the Marvel Rizzamatic Universe
Undergoing Cellular Rizzpiration
He Chose Charizzard
He Chose Rizzachu
Got the Rizzitenship
Creating a New Year's Rizzolution
The 13th Rizzon Why
Mordecai and Rizzby
Listening to 103.5 Rizz FM
Opened the 8th Gate of Rizz
He's the Rizzkage
Caught in a Rizzjutsu
Used the Sharizzan / Rizzegan
The 6 Paths of Rizz".split(/\n/).join(", ")

pp test 

Ruby Online Compiler

Write, Run & Share Ruby code online using OneCompiler's Ruby online compiler for free. It's one of the robust, feature-rich online compilers for Ruby language, running on the latest version 2.3.1. Getting started with the OneCompiler's Ruby compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as Ruby and start coding.

Read input from STDIN in Ruby

OneCompiler's Ruby online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Ruby program which takes name as input and prints hello message with your name.

name = gets.chomp               
print "Hello #{name}.\n" 

About Ruby

Ruby is a general purpose object oriented programming language developed by Yukihiro Matsumoto.

Key features

  • More commonly used in Rails applications.
  • Concise and simple to read and powerful too.
  • Open-source
  • Expressive features and visual appearance
  • Flexible language

Syntax help

Data types

Data typeDescriptionUsage
FixnumRepresents normal numbersx = 10
BignumRepresents big numbersx =9999999999
FloatRepresents decimal numbersx = 3.14
ComplexRepresents imaginary numbersx = 1 + 2i
RationalRepresents fractional numbersx = 1/4
BigDecimalRepresents precision decimal numbersx=1.0
HashRepresents key value pairs{"Website"=>"onecompiler","message" => "Happy learning"}

Variables

In Ruby, there is no need to explicitly declare variables to reserve memory space. When you assign a value to a variable, declaration happens automatically and a prefix is needed to indicate the following variable types.

Variable typeDescription
Local variablesScope is limited to the block of the variable initialization. Variable name must start with either _ or lowercase letter.
Class variablesClass variables belongs to whole class and can be accessible anywhere inside the class. Variable name must start with @@. They must be initialized before use.
Instance variablesInstance variables belongs to a instance of the class. They can be accessed from any instance of the class within a method. Variable name must start @
Global variablesScope is global and hence they can be accessible anywhere in the program. Variable name must start with $

Loops and conditional statements

1. If family:

If, If-else, Nested-Ifs are used when you want to perform a certain set of operations based on conditional expressions.

If

if(conditional-expression)
    #code    
end

If-else

if(conditional-expression)  
    #code if condition is true  
else   
    #code if condition is false  
end 

Nested-If-else

if(condition-expression1)   
    #code if above condition is true  
 elsif(condition-expression2)  
    #code if above condition is true  
elsif(condition-expression3)   
    #code if above condition is true  
...  
else   
    #code if all the conditions are false  
end  

2. Case:

Case is similar to Switch statement, where it is used to execute one set of a statement from multiple conditions.

case expression  
[when expression [, expression ...] [then]  
   # code ]...  
[else  
   # code ]  
end  

3. For:

For loop is used to iterate a set of statements based on a condition.

for variable in expression do   
  # code  
end

4. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while condition do   
 # code 
end  

5. Do-while:

Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

loop do   
  #code  
  break if conditional-expression  
end