Day4 - Hashes
Spent 30 minutes so far (1:40PM EST)
My current habit is to read other blog posts of fellow RoR travelers . Currently it’s just Josh Kemp (just read Nov 4th entry). I wish my good friend Nic Chapa who said he’s was going to start journaling, would as well.
I deliberately want to read about other’s journeys because it creates a support network for myself (and them too, even though there is no interaction). It’s a deliberate system for psychological support / validation, which is important for tackling challenging things (especially those that we are afraid of) — for me it’s coding.
Hashes — are an unordered list of data, each piece of data organized in a key/value pair.
Learning 1.
Shorthand for hashes => a_hash = {num_users: 5, total_num_posts: 100} ; compared to hash = {num_users => 5, total => 100}
Learning 2.
When displaying data via string_interpolation… #{a_hash[:num_users]} ; compared to #{a_hash[‘num_users’]}
Learning 3.
When iterating through a hash … the two parameters in the block are the key / value pairs.
hash.each do |key, value| … end ##### night_outs.each do |event, cost| … end