< Language Tutorials

Document stub.png This article is a stub. It may be incomplete, unfinished, or have missing parts/sections. If the article can be expanded, please do so! There may be suggestions on its talk page. (August 2018)

There are different types of data in Ruby, and most of these are shared by most other programming languages. They are:

  • booleans
    • Booleans are either true or false, similar to Boolean Blocks in Scratch (they can also either be true or false).
  • integers/floats
    • Although integers and floats are not the same thing, they are grouped together here, since together, they are simply numbers. Integers are whole numbers, and floats are decimal numbers (such as 54.0, 9.3, or 0.23).
  • strings
    • Strings are text. Some examples of strings are "Hello, world", "dog", or "47". The reason "47" is not classified as a integer or float is because it is inside quotation marks. Anything inside single quotes ('') or double quotes ("") are strings in Ruby. So, "47" is different from 47.
  • symbols
    • Symbols are shown as either :symbol_name or symbol_name:. There cannot be two or more of each symbol at once in a Ruby program. So, if :dog exists, there cannot be another :dog in the program at that time. This makes Ruby programs faster. There is a specific way to create hashes using symbols, shown at Language Tutorials/Ruby/Variables, Arrays, and Hashes.
  • nil
    • nil is nothing. If one sets a variable to nil with variable_name = nil, that variable is equal to nothing. It's useful for creating variables at a point in the program when a value is not yet known.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.