Iteration and Enumerable
Just finished my first week at a coding boot camp. First obstacles I had to overcome were these f***ing iteration methods and code blocks. What are pipes? So while you’re learning all of your cohort members name by having back to back icebreakers. You also have to learn to code.
So the main idea is moving through a list of something an array or a hash. Then we can grab data or even change data. Loops are dangerous because we can cause infinite loops, that could break your terminal. Conditionals will run the code until it returns false.
The best part of this is that we can do it in very little code.
Introducing ruby methods: select, map and find.
Great replacements.
Select returns an array of all elements in array which block returns a true value.
What is a block? Blocks group statements by do and end or curly braces. So within the blocks we have pipes that hold a variable that represents the individual element we are iterating over in the array.
Once you’ve mastered these methods you are on your way until the next thing that will keep you up at night.
\