Skip to content

Instantly share code, notes, and snippets.

@amysimmons
Created May 2, 2015 05:46
Show Gist options
  • Select an option

  • Save amysimmons/47fda32c50c9feb76ab2 to your computer and use it in GitHub Desktop.

Select an option

Save amysimmons/47fda32c50c9feb76ab2 to your computer and use it in GitHub Desktop.
Accessing data based on the object type

#Determining how to access data based on the object type

  1. Call .class on the object that we have to see what type it is
  2. If it is an array, we can use the array methods (ie .first, .sort [])
  3. If it is a hash, we can use the hash methods (ie .fetch, h[:foo])
  4. If it is something else, we can ask what methods it responds to by doing foo.methods - Object.methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment