Skip to content

Instantly share code, notes, and snippets.

@mbattur
Last active November 2, 2015 19:28
Show Gist options
  • Select an option

  • Save mbattur/22cbe7ae2ece6caa65c6 to your computer and use it in GitHub Desktop.

Select an option

Save mbattur/22cbe7ae2ece6caa65c6 to your computer and use it in GitHub Desktop.
2015.09.21 - Notes
Strings and numbers are known as primitive data types. Primitive data types are basically the smallest building blocks for Ruby programs. In the next exercise, you'll work with more building blocks.
Booleans are a primitive data type, just like Strings and Numbers. Booleans can have one of two values: true or false.
There's one more primitive data type to explore before moving on: the Symbol. Symbols are like strings, only with less functionality. A Symbol is designated with a colon (:) to the left of a word. Symbols can contain any alpha-numeric character, but they must start with a letter.
While "hello" + 3 doesn't make sense, you can mix strings and numbers if the return is meant to be a string. Combining strings and numbers is called string interpolation. String interpolation is the act of inserting a non-string value into a String, thus creating a new String. Interpolation is accomplished with the #{ } syntax.
The modulo operator – % – returns the integer remainder of a quotient. For example, when dividing 5 into 30, the remainder is 0 because 5 divides evenly into 30 six times. Division does not always work out evenly though. When dividing 8 into 30 the outcome is 3.75. The remainder of this division is calculated by multiplying .75 by 8 which results in an integer remainder of 6.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment