Ruby: Data types & Variables

Programming in Ruby

The benefits of using Ruby for web development:

  • High level language so its easy to understand
  • Interpreted
  • Object oriented
  • Easy to use

Starting with “how to code using Ruby”; for now we discuss only the 3 mainly used data types:

  1. Numbers
  2. Booleans
  3. Strings

Note: Do not use quotation marks ” ” for the boolean values otherwise Ruby will think it to be a string value.

Lets do a small exercise here that shows how to declare variables and assign them values.

my_number = 25

my_boolean = true

my_string= “Ruby”

Declaring variables in Ruby is quite simple. Just write the name and assign it a value using the = operator

For eg: Lets set a variable my_num to the value 150

To do so we simply do as follows:

my_num=150

Published by

Rocking Londoner

www.rockinglondoner.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s