You've heard the phrase “diamonds are a girl's best friend”? Well, rubies are a nerd's best friend, and in this tutorial I am going to show you why. We'll discuss operators, conditionals, loops, hashes, and arrays in Ruby. And that's not all.
Ruby Operators and Arrays - Home on the Range (Page 4 of 4 )
I wonder exactly how buffalo play. And what. Maybe when no one is looking they pull up an old log, light up a hickory pipe, and play a good game of chess, huffing and blowing smoke and mutter pip pip, cheerio a lot.
Ranges in Ruby don't have buffalo on them (well I guess they could if you really wanted). They allow you to work with a set of items. For instance, January through December would be a range. A group of numbers would also be a range, as shown below.
your_range = 1..10
This would print out the following:
etc. You can also use the ... operator, which simply omits the final value:
your_range = 1...10
Would print the values 1 through nine only. We'll get more into ranges in the next tutorial.
That's right, I tricked you. Here you thought we would be doing Conditionals and Loops and all kinds of crazy statements. Well you were wrong. It was just a brilliant trick to get you to read the next tutorial (well that and I ran past my word limit). So stick with me and read the next tutorial, where we will get down and dirty with Ruby.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.