Ruby Control Structures - PowerPoint PPT Presentation

About This Presentation
Title:

Ruby Control Structures

Description:

Times New Roman Verdana Bnr697 Ruby Control Structures Statements Conditions Looping For loops Notice the Range ... – PowerPoint PPT presentation

Number of Views:70
Avg rating:3.0/5.0
Slides: 7
Provided by: Venka85
Learn more at: https://www2.cs.uh.edu
Category:

less

Transcript and Presenter's Notes

Title: Ruby Control Structures


1
Ruby Control Structures
2
Statements
  • Statements dont need
  • You write one statement per line (like you
    normally do anyways)
  • If you want to put multiple statements on a line,
    you may use the optional

3
Conditions
  • if statement does not need
  • Short forms

4
Looping
  • while loop is similar to what youre used to

More concise form
5
For loops
There are some other cool ways as well, but
well have to wait for that until we learn about
blocks
6
Notice the Range
  • We used 1..10 and 1..val
  • Range is a first class citizen in Ruby
  • You can create range objects
  • It comes in handy in various situations well
    see these when discussing collections
Write a Comment
User Comments (0)
About PowerShow.com