Posts

Showing posts with the label loops

Ruby - Loops

Image
Greetings!!! Loop does exactly what you think it would.   It loops through a bit of code over and over and over again until you tell it to stop.   And the way that we define a loop in Ruby is by simply having loop space and   then word do, then the code that we want to repeat will be on a new line after that   and then on a new line once that's done, we would have the word end.   Everything from do to end would be called a code block and we are going to be   talking more about code blocks a little later on and going into depth with them,   because they're a really useful thing. This really the first time we've encountered them, so just make a mental note   this is our first code block.   Loop will take a code block and just loop through that block over and over and over again.   In fact, if we were to go to IRB  and just type in something that was a really   simple look like this, it would just keep looping and i...