Ruby's Basic Features: Blocks, Loops, Arrays & more
Like any other programming language, Ruby has a number of basic features that make up the code. Learn what these features are and how to use them in your code.
In any programming language, you need some way to prevent naming clashes. This is especially true when you're using at least one third party library, where you have no control over the naming scheme. In the past, naming conventions would be used. It's not uncommon to see C programs with names like [i]mylibrary_some_function[/i]. However, Ruby has a more powerful solution: modules.
Storing key/value pairs in Ruby doesn't always need to be accomplished by using a hash. You can also use the Struct and OpenStruct classes.
This article explains and teaches how to use a associative arrays (hashes) as a way to store multiple variables in one data structure.
This article explains and teaches how to use an array and an associative array (hash) as a way to store multiple variables in one data structure.
How to use blocks in Ruby.
The basic IO methods are often overlooked by many Ruby programmers. How often have you used the
gets and
puts methods without giving them a second glance? Learn all the features of these methods to better put them to use in your code.