3.8 Summary

We discussed classes, variables, constants, and key data types such as strings and integers. At this point, you should know how to create a variable in Ruby and how to assign values to your newly created variable.

3.8.1 Key Concepts

  • Ruby programs can be created/edited in any text editor (as defined previously), so long as the editor can save files as plain text. It is highly recommended that you use an editor suited for writing programs.

  • When naming variables, it is a common practice to separate each word in a variable name with an underscore (_).

  • Programming languages use various data types to perform various operations. Ruby uses many data types, including integer (Fixnum and Bignum), float, string, and Boolean.

  • It is important to understand the syntax behind simple mathematical operators. Mathematical operators will often be used when programming. Pay attention to the order of operation.

  • To output information onto the screen, use the puts command. To input information from the user, use the gets command.

  • The three types of programming errors are syntax errors, logic errors, and type errors. Type errors often arise from mixing data types that cannot be mixed, such as integers and strings.

  • Conversion errors are a subset of type errors.

3.8.2 Key Definitions

  • Variable: A piece of data attached to a name, class, and memory location.

  • Instantiate: In this simple initial presentation, creating a variable. See Chapter 9 for more information.

  • Constant: A ...

Get Computer Science Programming Basics in Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.