have a hash with a default value  

Revisiting codecademy Ruby… it says:

If you have a hash with a default value, and you try to access a non-existent key, you get that default value.

irb(main):001:0> a = Hash.new
=> {}
irb(main):002:0> b = Hash.new(0)
=> {}
irb(main):003:0> a["john"]
=> nil
irb(main):004:0> b["john"]
=> 0
irb(main):005:0> a == b
=> true

This is great…

 
0
Kudos
 
0
Kudos

Now read this

Rails prototype Post-It: Lesson 1

This is what I have done on week 1, course 2 of Tealeaf Academy: Database tables - schema view # posts: ‘url’, ‘title’, ‘description’ users: ‘username’ comments: ‘body’ categories: ‘name’ foreign keys (and primary keys) Migration files #... Continue →