Sometimes when you have a group of people, you need to randomly select one of them to do something. Maybe that’s to go first in a game, to do a chore, or just for fun you want to see who is the last person standing (think musical chairs). One old game that’s sometimes used to pick somebody is to take a bundle of straws (or sticks or pencils), make them all the same size except for one of them, and then randomly pick from the bundle. Whoever gets the short straw is “out” (or wins, depending on how you look at it!).
This project is going to dive a little more deeply into the Array object you’ve been using in some of the prior projects. Up until now, I’ve just used it with some basic functionality, but here, you’ll see that it’s a pretty powerful tool. I’ll show you a few different ways to use arrays, and as a bonus, I’ll show you a few shortcuts you can use when working with arrays and classes.
You’ll use Atom to create and edit your program. You’ll store this project in a single Ruby file. And you’ll use the terminal program to run, test, and play around with the short straw code.