A Simple Ruby Program : Ruby Interpreter « Language Basics « Ruby






A Simple Ruby Program

# This file's name is intro.rb 
puts "Hello, world!" 
numOfCoins = (10 + 20) * 2 / 3 
puts "You have #{numOfCoins} coins." 
puts 'You have #{numOfCoins} coins.' 
puts 'You have ' + numOfCoins.to_s + ' coins.' 

 








Related examples in the same category

1.Ruby Interpreter option list
2.operators are actually implemented as method calls
3.Ruby is case-sensitive
4.Explicitly extend a statement onto the next line with a backslash