Monday, 3 March 2014

How To Assign Basic Values To Variable In Ruby

Assigning Values To Variables in Ruby is a pretty easy thing to do. Once you learn it there's no end to the fun you can have with this programming language.

Here are a couple of examples as how you can manipulate variables and their values in Ruby.

irb(main):001:0> x = 50
=> 50
irb(main):002:0> y = 100
=> 100
irb(main):003:0> puts x + y

Firstly we assigned numbers to the variables x and y. Then we used the 'puts' method to output the combined value of x + y to arrive at our total of 150! Simples!

No comments:

Post a Comment