Presentation is loading. Please wait.

Presentation is loading. Please wait.

Familiar concept Names for storage Choosing names Ruby rules Program Variables Click icon to hear comments.

Similar presentations


Presentation on theme: "Familiar concept Names for storage Choosing names Ruby rules Program Variables Click icon to hear comments."— Presentation transcript:

1 Familiar concept Names for storage Choosing names Ruby rules Program Variables Click icon to hear comments

2 Common use of variable names Setting HOURS and MINUTES on a clock Preset timings on microwave ovens – Popcorn, pastry, soup Use in algebraic formulas – Circumference = 2 X r X pi Click icon to hear comments

3 Variable -” named memory location ” CPU can only manipulate what is stored in memory Programming languages let people use words to specify memory locations and actions Power of computers is directly related to the ability to rapidly store, access, and modify data values Every programming language has rules for choosing variable names and their usage Click icon to hear comments

4 General rules for variables SingleWord (no spaces) Be descriptive and relevant Start with a lowercase letter (upper case for constant) Valid Variable names: totalSales area bitsPerSecond Poor choices: My First Name 23yearsold X Click icon to hear comments

5 Ruby rules for variables Start with a letter No spaces Underscore is allowed @, @@, and $ are scope modifiers May not be the same as a key word May not start with punctuation, like dot or parentheses Constants start with an upper case letter Click icon to hear comments


Download ppt "Familiar concept Names for storage Choosing names Ruby rules Program Variables Click icon to hear comments."

Similar presentations


Ads by Google