Skip to content

Instantly share code, notes, and snippets.

@jnewman12
Last active December 19, 2016 22:09
Show Gist options
  • Save jnewman12/df2f02e3165c6ab74a1dd76b6b86c714 to your computer and use it in GitHub Desktop.
Save jnewman12/df2f02e3165c6ab74a1dd76b6b86c714 to your computer and use it in GitHub Desktop.
Ruby array, hashes, and blocks lab

Ruby Lab

Arrays, Hashes, and Blocks


Part 1

  • Do the following in irb or repl.it.
  • get with your pair (group) and make a Hash, called student, describing you!
  • it can be anything you want, but try to make it use multiple values (arrays, a nested hash, string, boolean, numbers, etc)

Part 2

  • take the hash you just made, and loop over it
  • output the contents of your hash to your console

Part 3

  • take your code you used to loop, and make a method out of it
  • name it anything you want, but have it take a hash as an argument
  • make sure it outputs the contents of your hash to the console

Part 4

  • number operations are very common in ruby
  • let's build 2 methods: sum and average
  • have your methods take an array as an argument
  • use any number array you want, but try it with a decent amount of indexes like
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

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