Skip to content

Instantly share code, notes, and snippets.

@scottmascio2115
Created August 11, 2013 22:43
Show Gist options
  • Save scottmascio2115/6207218 to your computer and use it in GitHub Desktop.
Save scottmascio2115/6207218 to your computer and use it in GitHub Desktop.
reflect_on_learning.

List 10 topics

  1. Driver code
  2. Recursion
  3. Looping
  4. Enumerables
  5. Arrays
  6. Ping pong pairing
  7. Debugging
  8. Pseudocode
  9. Refactoring
  10. Blocks

Choose two and write a description

Driver code- Driver code is an efficent way to test each part of your code as you write a method. Every time your write a new peice of code, create a test to see if that code is running how you thought it would. Your driver code should display true if your code is running properly and false if your code is not doing what you want it to do.

Enumerable- The enumerable module is a list of methods that can be used on collection classes for the ability to sort the collection based on a specification that you give.

Write code to illustrate one of your descriptions

Driver code def empty_hash {} end puts empty_hash == {}

Your code here

array = ["dog", "cat", "rat"] p array.any? {|word| word.length >= 5}

using the enumerable any go through each element in the array and determine if the length is greater than or equal to 5

@tarynsauer
Copy link

Hi Scott, I really like your enumerable method example. I haven't used the any? method in any of the challenges yet, but I think that it's a good one to keep in mind. It seems like it could be pretty useful. To improve your code, you could add spaces between the curly brackets and pipes in the block, following the Ruby style guide:

array = ["dog", "cat", "rat"]
p array.any? { |word | word.length >= 5 }

This helps make the code a bit more readable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment