Test Yourself: Ruby Basics

How well did you learn what's been taught in the previous lessons?

Scroll down...

Content

Resources

Comments

Some questions you should be able to answer before moving on to the assignments.

Ruby

  • What attributes of Ruby help it encourage "programmer happiness"?
  • What is an "interpreted" language?
  • What is IRB?
  • What are Objects?
  • What are Methods?
  • What are Classes?
  • What are Blocks?
  • What is an Array?
  • What is an Iterator?
  • What are hashes?
  • What is a library?
  • What is a gem?

Numbers, Operators and Expressions

  • What's the difference between an Integer and a Float?
  • Why should you be careful when converting back and forth between integers and floats?
  • What's the difference between =, ==, and ===?
  • How do you do exponents in Ruby?
  • What is a range?
  • How do you create a range?
  • What's the difference between (1..3) and (1...3)?
  • What are three ways to create a range?

Strings

  • What's the difference between single and double quotes?
  • What is string interpolation?
  • What are escape characters?
  • What are line breaks?
  • How do you make other things into strings?
  • How do you concatenate strings?
  • How do you access a specific character or substring?
  • How do you split up strings into arrays?
  • How are strings and arrays similar?
  • How do you get and clean up user input on the command line?
  • What does it mean that strings are "mutable" and why care?
  • What is a symbol?
  • How is a symbol different from a string?
  • How can you center or right-justify a string?

Arrays

  • What are three ways to create an array?
  • What should you store in arrays?
  • How do you prepopulate the array with default data?
  • How do you access items in an array?
  • How can you access a specific group of items in an array?
  • How do you modify the items in an array?
  • What is the difference between push/pop and shift/unshift?
  • What is the shovel operator?
  • How is > arr.pop different from > arr[-1]?
  • How is pushing or <<ing another array into your array different from just adding them together?
  • How do you delete items in an array?
  • Why should you be careful deleting items in an array?
  • How can you convert arrays to strings?
  • How can you convert from other data types to arrays?
  • How can you figure out if an array contains a particular value?
  • How do you find the biggest item in an array?
  • How do you find the smallest item in an array?
  • How do you remove any duplicates from your array?
  • How to you find out how big an array is?
  • How do you put an array in order?
  • What are the naming conventions for arrays?

Hashes

  • What is a hash?
  • What are keys and values?
  • How is a hash similar to an Array?
  • How is a hash different from an Array?
  • What are 3 ways to create a hash?
  • What is the "hash rocket"?
  • How do you access data in a hash?
  • How do you change data in a hash?
  • What types of data are good to store in a hash?
  • What are options hashes?
  • How do you delete data from a hash?
  • How do you add hashes together?
  • How do you list out all the keys or values?
  • How do you see if the hash contains a key or value?
  • What is a set?

Dates and Times

  • How do you get the current date and time?
  • How do you find just the Year? Month? Hour? Second? Weekday?
  • How do you create a Time specifically for 12/25/2013?
  • How do you find how many days have passed between two Time's?
  • What's the difference between UTC and GMT and Local times?
  • How would you find out the time that was 100 seconds ago? 10 days ago?

Other Random Stuff

  • What is nil?
  • How do you check if something is nil?
  • What's the difference between nil and blank and empty?
  • Are the following nil or empty?
    • " ", "", [], [""], {}
  • What's the difference between puts and p and print?
  • What does inspect do?
  • What do +=, -=, *= and /= do?

Conditionals and Flow Control

  • What is a "boolean"?
  • What are "truthy" values?
  • Are nil, 0, "0", "", 1, [], {} and -1 considered true or false?
  • When do you use elsif?
  • When do you use unless?
  • What do || and && and ! do?

Iteration

  • What are the two ways to denote a block of code?
  • What is an index variable?
  • How do you print out each item of a simple array [1,3,5,7] with:
    • while?
    • for?
    • #each?
    • #times?
  • What's the difference between while and until?
  • How do you stop a loop?
  • How to you skip to the next iteration of a loop?
  • How would you start the loop over again?
  • What are the (basic) differences between situations when you would use while vs #times vs #each?
  • What does nesting loops mean and when would you use it?

Blocks

  • How is a block like a function?
  • How is a block different from a function?
  • What are the two ways to declare a block?
  • How do you return data from a block?
  • What happens if you include a return statement in a block?
  • Why would you use a block instead of just creating a method?
  • What does yield do?
  • How do you pass arguments to a block from within a method?

Enumerable

  • Why are modules useful?
  • What does #each do?
  • What does #each return?
  • What does #map do?
  • What does #map return?
  • What does #select do?
  • What does #select return?
  • What is the difference between #each #map and #select?

Writing Methods

  • How many things should a method ideally do?
  • What types of things should a method modify?
  • What should you name a method?
  • What does self mean?
  • What do you need to do to create your own Ruby script file?
  • How would you run a Ruby script from the command line?
  • How can you check whether your script was being run from the command line?

Running Scripts

  • How do you run a Ruby script from the command line?
  • What is a "Shebang" line?
  • How can you run a Ruby script without even using the ruby keyword on the command line?
  • How do you require a script or gem in IRB?
  • What's the difference between require and load?
  • How do you pass a variable to a script from the command line?
  • How do you access that variable from within your script?
  • How can you check whether your script was run directly from the command line or as part of another script instead?


Sign up to track your progress for free

There are ( ) additional resources for this lesson. Check them out!

There are no additional resources for this lesson just yet!

Sorry, comments aren't active just yet!

Next Lesson: Solving Problems with Ruby