July 15, 2024

My Journey Of Learning Programming Through Flatiron School #9

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.

So the other day I was encountering a lot of issues with one of my lessons with The Flatiron School. Me and one of the instructors were having some issues with getting some of the test to pass and he mentioned he could get a more senior instructor to screen share with me. I did not know this was an option and it was an awesome experience. They use the software TeamViewer which I have installed earlier but never really have used it before. Once I gave him the necessary authentication, he logged into my computer and was able to test what I was doing on his end with me. While he was showing me this he also got to show me some other shortcuts and bash commands that would help me further in personal projects.

This was an awesome addition to what The Flatiron School offers with its tuition. It was great to see a fast response to my question as well an in-depth look at other ways I could perform the same task.

The instructor also gave me insight to the structure of the school and the importance of moving linearly through the school. I was excited to hear the in the beginning, they keep you constrained to a closed environment (learn.co IDE). Then, with progress, they slowly integrate you to an open sandbox environment on your local machine.

They do this because most students are not ready to have full control of their environment prior to understanding some of these foundational concepts. Once you progress further in the school you will gain a greater understanding of the structure of programming, they introduce these core concepts linearly so you have a smooth transition to an open local sandbox environment.

But enough about that!

Intro to loops:

So a method, which we covered earlier is a form or abstraction. Within methods, loops allow us to tell the program to do something over and over again. Allowing us to abstract away the actual mechanics of enacting the same or similar lines of code.

The above code runs the puts “something” command 10 times. There are a few different ways of doing this, but the simplest way is using the loop keyword.

Enacting this, puts “something” an infinite amount of times because we never specified where to break out of our program. Remember use control + c to break out of program.

Remember that loops start with the loop keyword and are opened by the following do and end block. We can use the break keyword inside the body of our loop to exit our loop and continue with the rest of our program.

This will run the loop the amount of times specified until the counter is greater than or equal to 10, thus printing our message 10 times and breaking. With this construct we can break a loop on any condition.

While and until loops:

The while construct will keep executing a block as long as a specific condition is true, unlike the until condition which is the inverse of the while loop. And until loop will keep executing a block until a specific condition is false.

Loops are a foundational concept of most programming languages including Ruby. If you understand loops and their purpose you will get a better grasp of what you are able to accomplish with that language.

Leave a Reply

Your email address will not be published. Required fields are marked *