Skip to content

aenbar/looping-loop-000

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

The Loop Construct

The first looping construct that we'll discuss is loop. This is the simplest looping construct that we have in Ruby. It simply executes a block (the code that is between the do and end keywords). Try this in IRB in your Terminal:

loop do
  puts "I have found the Time Machine!"
end

This will output I have found the Time Machine! an infinite number of times in your Terminal. Use Control + C to break out of the loop in your terminal.

Instructions

This is the first in a series of short exercises to help you get the hang of looping constructs.

  1. Fork and clone this lab.

  2. There are no tests for this lab! Code your solution in looping.rb:

    • It's your first year at Hogwarts and you're having a tough time getting the hang of that levitation spell. Fill out the content of the method looping to puts out the levitation charm "Wingardium Leviosa" using the loop keyword an infinite number of times.
    • Beneath your method definition, call your method by typing the name of the method, looping.
  3. Then, run the file by typing ruby looping.rb in your terminal from the directory of this lab. You'll be stuck in an infinite levitation loop! Hit Control + C to exit the infinite loop.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%