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

code-lucidal58/ruby_inception

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Ruby_Novice

All you need to know to start about Ruby

Ruby is a general purpose language, commonly used in Rails applications.

Ruby is interpreted (does not need a compiler). It is object-oriented and case-sensitive language. Ruby does not require semicolon(:). Variables in Ruby are declared as:

my_number = 25
my_boolean = true
my_string = "Hello"
puts my_number

It supports simple mathematical operations like: + - * / % **

There are two methods that are used to print on screen: puts and print . print prints content as it is. puts adds a new line to the content. There are no parentheses.

print "Hello There"
puts "How are you?"

Common Methods in Ruby

.length is called on a string or string variable. It returns the length if the string.

puts "Your_Name".length

.reverse is called on a string or string variable. It returns the string in reverse order. It does not modify the original string.

puts string_variable.reverse

.downcase and .upcase is used to return string in all lowercase and all uppercase respectively. Multiple methods can be called in single line, one after the other.

puts string_variable.upcase.reverse

Comments

Single line comments are written with hash(#) in the start. Multi-line comments start with =begin and end with =end .

# This is a single line comment
=begin 
This is a
multiple line comment
=end

Local variables are written in all small letters separated by underscore. E.g. my_name, simon

About

All you need to know to start about Ruby

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published