The 'split' method isn't the only fish in the sea. The 'partition' method is similar, but doesn't consume the split string.
Ever since Ruby Version Manager was released, it's been the de facto standard for installing Ruby.
Often ignored or only glossed over, control structures and loops are very important to master. While they're very straightforward in languages such as C, there are several subtleties to understand before you can really leverage the conditional and loop statements in Ruby.
The 'split' method isn't the only fish in the sea. The 'partition' method is similar, but doesn't consume the split string.
The Flip-Flop operator is an odd thing. It uses the range syntax, but doesn't produce a Range object. Sometimes, it's true, sometimes it's false, but most of the time it's just confusion. Should you be using it in your code? That's up to you, but you really should know about the flip-flop operator, should you ever encounter it.
Most languages don't have any concept of a "range." To iterate over some numbers, you either define a minimum and maximum and iterate with a typical loop, or use a combination of comparison operators. Ruby, on the other hand, has Ranges out of the box, and they can be used in a number of intuitive ways.
Read all about Ranges here.
Did you know that you can make any of your classes act like Ruby collections? You can use any of the methods you'd typically use on collections (like Arrays and Hashes) on your classes by simply implementing the each method and including the Enumerable module. Also, if the elements of your collection implement the spaceship (<=>) operator, your collection can even be sorted!
Read more about using the enumerable module.
©2012 About.com. All rights reserved.
A part of The New York Times Company.