Giter VIP home page Giter VIP logo

looping-loop-dc-web-062518's Introduction

The loop Construct

Objectives

  1. Understand how the loop construct works
  2. Build a method that utilizes the loop construct

Introduction

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 contain a loop that puts the levitation charm "Wingardium Leviosa" 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.

View The loop Construct on Learn.co and start learning to code for free.

looping-loop-dc-web-062518's People

Contributors

sophiedebenedetto avatar annjohn avatar sarogers avatar markedwardmurray avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.