Numbers, Operators, and Expressions

Numbers, Operators and Expressions:

  1. What’s the difference between an Integer and a Float?
    Integers are whole numbers. Floats are decimals
    More info here: http://docs.railsbridge.org/ruby/numbers_and_arithmetic
  2. Why should you be careful when converting back and forth between integers and floats?
  3. What’s the difference between =, ==, and ===?
    = is assignment operator (ie. sets a = b)
    == is equal comparison operator (checks if two variables have equal values)
    === is identical comparison operator (checks if two variables are equal values and are the same type)
  4. How do you do exponents in Ruby?
    Use two * together. I.e.: a**2 is a to the second power
    http://www.tutorialspoint.com/ruby/ruby_operators.htm
  5. What is a range?
    A range is a set of values with a start and an end.
  6. How do you create a range?
  7. What’s the difference between (1..3) and (1...3)?
    (1..3) includes the numbers 1-3. (1…3) does not include the last number, so just numbers 1-2.
  8. What are three ways to create a range?
    Range as a sequence, range as an interval, range as a condition.

Resources:
http://docs.railsbridge.org/ruby/numbers_and_arithmetic
http://www.tutorialspoint.com/ruby/ruby_operators.htm
http://ruby-doc.org/core-1.9.3/Range.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s