April 10, 2003

More Ruby!

Some more funky Ruby language tricks:

a = 10
b = 20
puts "a = #{a}, b = #{b}"
a, b = b, a
puts "a = #{a}, b = #{b}"

results in the following being printed:

a = 10, b = 20
a = 20, b = 10

ie. parallel assignments are allowed :)

The following:

0.upto(9) { |x| print x, " " }

prints:

0 1 2 3 4 5 6 7 8 9

Posted by crafterm at April 10, 2003 05:13 PM | TrackBack
Comments
Post a comment









Remember personal info?