Advertisement
solidsnake

11/24

Nov 23rd, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.78 KB | None | 0 0
  1. HASH
  2.  
  3. driver =
  4. {
  5.     :name => "Happy",
  6.     :id_number => "12345"
  7. }
  8.  
  9. my_hash =
  10. {
  11. :name => "Car",
  12. :color => "red",
  13. :numwheels => 4,
  14. driver: driver # if colon is on the right hand side, it passes driver value
  15. }
  16.  
  17. puts my_hash[:name],
  18. puts my_hash[:color],
  19. puts my_hash[num_wheels => 4
  20. puts my_hash[:driver][:name]  # trying to get key name from my_hash, from driver
  21.  
  22. my_hash.each do |item|
  23.     puts item
  24.  
  25. my_hase.each_pair do |key, value|
  26.     puts "#{key}; #{value}"
  27.  
  28. Model - data
  29. View - interface
  30. Controller - flow of data/dictates where to go
  31.  
  32. User interacts with framework. Whatever you put in VIEW doesnt say where the user has to go, controller does that.
  33.  
  34. First entry point should be the controller component.
  35.  
  36. User will request
  37.     a) url
  38.     b) data/hash
  39.  
  40. RESPONSE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement