Arrays, Hashes, and Blogs, Oh My!

March 13, 2015

Lets talk about your storage needs. That might actually end up being a pitch some salesman uses to try to sell you new cloud storage in the near future. For the the immeadiate future, let's talk about storing small and easily manipulatable data methods. My friends, Array and Hash. The choice betweeen the two depends on what you are trying to keep track of.

A single instance of data will probably best served by an array. What does that even mean? So, you have a set of numbers, 1,2, and 3. The array will easily store those in linear, numbered fashion in a set of brackets[1,2,3]. Each number will have a corresponding address, or index. The first item in any array will be at the index [0]. So the number 1 will be index [0], and 2 will be at index [1]. You can have any thing stored in an Array, but it will always be stored with that very reliable indexing method. For instance, the array ["bannana", 5, true] will have the index of bannana at [0] and true at[2]. But there are limitations.

What happens if you need to store data points with corresponding titles, descriptions that require a bit more sophistication in that cataloguing process? That's where Hashes come in to play. Let's say your trying to keep track of baseball players with their teams. By the way, I am of the firm belief that baseball is usuable in almost any metaphorical situation. Anyhoo, you have Lincecum who plays for the Giants, Kershaw who plays for the Dodgers, and Reddick who plays for the A's. The best way to keep track is to make it look like this, {Dodgers: Kershaw,
Giants: Lincecum,
A's: Reddick
}
This way, you can actually look up who plays for the Dodgers or who Reddick plays for without having to use a simple index. I hope that's relative simple. Again Soon,
Staunton