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)
- # sign is used for comments eg.
- > 20 + 30 # Adding two integers
- For string "" are used e.g
- > "Ruby Language"
- > "" #Empty string
- + sign is used for concatenating eg.
- > "Ruby" + "Language"
- 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.
- Math.sqrt(99)
- Math.cos(30)
0 comments:
Post a Comment