My name is Mason Ellwood, and I’m currently working on Flatiron School’s Online Full Stack Web Development Program. Each week, I’ll be writing about my experience, what I’m learning, and tips on learning to code.
As the graphic above states, based on jobs needed and languages required, Ruby should be fairly low on the totem pole in terms of necessity to learn. Even at my last job none of the other developers knew Ruby….
So why does this course involve such an in-depth dive into Ruby?
I remember talking to my friend Wyatt. He was just hired on as lead project architect building software for a company with Ruby. I asked him how he was with Ruby and he said he had never used it…. But he said that he took a look at it and it java mixed with a few others and should be able to pick it up within a month. This is the conclusion I came to as well. Knowing your first programming language is the hardest part of becoming a programmer. Once you have mastered one, the others can come to you rather quickly.
Once I understood this, I was a little more content with the courses.
Iteration and Abstractions:
So there are four types of loops:
Looping occurs when you tell your program to do something a certain number of times.
Iterations occur when you have a collection of data (array), and you operate on each member of that collection.
“You don’t use three to four lines to express iterations, you use on word.” – Kent Beck
“Being abstract is something profoundly different than being vague… the purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise.” – Edsger Dijkstra
An iteration is a word referred to each step or each execution of a block. It is the singular execution of a sequence of code (we call a block) within a loop. Each yields elements one at a time to every iteration of the block.
The each method takes each element of the brother array one at a time and passes or yields it into the block between the do/end keywords. Each yield each item of the collection on which it is called to the block with which it is called. Each doesn’t need a separate counter variable and manual incrementation of that variable to know how many times to do something instead they use the number of items in a collection. The each method will always return the collection on which it was called as well.
So if you would like to iterate over an array and change some things, you will need to then pass that newly formed data into a new array.
Using loops and iterations are like the meat of Ruby. I feel like every lesson I have completed for the past week has been iteration after iteration. Once you dive into the code yourself, you will understand just how important these are to master and to be very familiar with.