Storing Data in Variables - Working with Variables
To get started with variables in Ruby, follow these steps:
- Enter this Ruby code in a new file, variables.rb:
Code:
temperature = 36
puts The temperature is + String(temperature) + .
temperature = temperature + 5
puts Now the temperature is + String(temperature) + .
- Save the variables.rb file.
- Run variables.rb to see the result:
Quote:
C:\rubydev>ruby variables.rb
The temperature is 36.
Now the temperature is 41.
|