Skip to content

Latest commit

 

History

History
52 lines (29 loc) · 945 Bytes

File metadata and controls

52 lines (29 loc) · 945 Bytes

Basics

Data Types

my_num = 15
my_string = "Tushar"
my_bool = true

puts my_num, my_string, my_bool
15
Tushar
true

Ruby is a dynamically typed Language, as we see in the above code, we assigned a number, a string value and a boolean to three different variables

'puts' is a function that takes a list of arguements and prints to console on a new line, You may use print statement as well, the only difference is, it prints in continuation.

print my_num, my_string, my_bool 
15Tushartrue

my_num, my_string and my_bool are variables which are holding different objects. For naming variables in ruby we use snakecase as a convention.

Everything is a an Object in Ruby,

Everything!

To find out class of a ruby object we can call a 'class' method on any object.

puts my_num.class() , my_string.class() , my_bool.class()
Fixnum
String
TrueClass