Skip to content
This repository has been archived by the owner on May 23, 2020. It is now read-only.

Latest commit

 

History

History
36 lines (34 loc) · 1.12 KB

part_0_introduction.md

File metadata and controls

36 lines (34 loc) · 1.12 KB

Introduction

Ruby is interpreted (does not need a compiler). It is a case-sensitive language. It does not require semicolon(:) for termination. Ruby doesn't care about whitespace. Hence no need to worry about indentations. The language performs sequential execution.

Generating output on screen/console

There are three methods that are used to print on screen: puts, print and p. print prints content as it is. puts adds a new line to the content. There are no parentheses. p prints the content along with the indication of the data type.

print "Hello There"
puts "How are you?"
p "I am writing a program"

The output on screen will be:

Hello ThereHow are you
"I am writing a program"

The last line of output has double quotes. This represents that it is a string. NOTE: This is a valid program. This will not generate any output.

"Hello World"

Comments

Comments are created using # (hashtag). Multiline comments are passed using =begin and =end keywords.

# This is my first program
puts "Hello World"
=begin 
This is a
multiple line comment
=end