Ruby (Programming Language)

Tutorial Title: Ruby (Programming Language)

Course: Web Engineering

Instructor: Muhammad Samim


Note: Copy and paste commands in terminal (irb) after sign >



1. Displaying message and calculating values
  • Open terminal by pressing Ctrl + Alt + t
  • type irb and press enter now you can apply following Ruby commands
  • > "Hello Everyone"
  • > puts "Hello Everyone"
  • > 3 + 3
  • > 4  * 4
  • > 5 ** 6    (** means 5^6)
2. Comments
  • # sign is used for comments eg.
  • > 20 + 30 # Adding two integers
3. Strings
  • For string "" are used e.g
  • > "Ruby Language"
  • > "" #Empty string
4. Concatenating
  • + sign is used for concatenating eg.
  • > "Ruby" + "Language"
5. Variables
  • Ruby auto detect data type of variables so no need to specify data type for variables
  • > b = 4 + 4
  • > a = "Any Message"
  • > first_name = "Muhammad"
  • > last_name = "Samim"
  • > first_name + " " + last_name #Displaying first name and last name together.
6. Interpolation (Built in function of Ruby)
  • Math.sqrt(99)
  • Math.cos(30)
7.
SHARE

Muhammad Samim

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment