Ruby Expressions

Watch out! This tutorial is over 2 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.
Tutorial Difficulty Level    

This is the first in a series for beginners on the Ruby Programming Language. Note that Ruby is a programming language. Ruby on Rails (“RoR”) is a web-application framework that is implemented in Ruby. Do not confuse the two. We will not covering Ruby on Rails in these tutorials.

These tutorials will be gather together under the tag #RubyTuesday, as we will be posting one each week from today to the end of term.  Ready? Here we go…

For information on how to run your Ruby programs, see the Hello World tutorial. Here’s this week’s code snip:

The variables shown in this example are “local variables”. (We’ll explore other possibilities later.)

Names are mostly conventional: letters, underscore, and digit, not starting with a digit. Local variables must start with a lower-case letter.

Variable types are dynamic: Assignment transfers both and type, not just value. Variables are not declared with a type, and assignment does not need to perform conversion.

Obviously, the + concatenates strings, as in Java and C++.

The printf function is lifted from plain C.