Skip to content

Instantly share code, notes, and snippets.

@QuillyT
Created January 20, 2016 22:38
Show Gist options
  • Save QuillyT/f4695dbd709e6f24f30c to your computer and use it in GitHub Desktop.
Save QuillyT/f4695dbd709e6f24f30c to your computer and use it in GitHub Desktop.
def create_enrollments_hash(district, year, percentage)
build_or_check_hash(enrollments, district, year)
unless percentage == nil
enrollments[district][type][year] = percentage
end
end
def build_or_check_hash(a_hash, *some_keys)
temp_hash = a_hash
some_keys.each do |key|
temp_hash[key] = {} if temp_hash.nil?
temp_hash = temp_hash[key]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment