- A variable as a word used to store a value (information) in programs.
- To assign a value to a variable, use '=' operator. The name of variable in the left and value of this variable in the right.
welcome = 'Welcome to Ruby Programming'
one = 1
price = 10.25
In above examples, welcome, one and price are variables. In there:
- welcome has value is 'Welcome to Ruby Programming'
- one has value is 1
- price has value is 10.25
Now we can reference to variables like that:
irb:001> welcome
=> "Welcome to Ruby Programming"
irb:002> price
=> 10.25
# string
hello = "Hello World!"
# number
money = 1000
price = 100.25
# booleans
true_val = true
false_val = false