-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashes.rb
More file actions
37 lines (31 loc) · 817 Bytes
/
Copy pathhashes.rb
File metadata and controls
37 lines (31 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#Allows us to set up labeled data.
#Look up value by its key. (key - value pairs).
# Symbol format is most efficient.
#String Hash
string_post = {
"date" => "6/10/16",
"title" => "About my Turtle",
"author" => "Tom Greene",
"body" => "I just saw my turtle surfing in the ocean!"
}
p string_post[:author]
string_post[:author] = "Sarah Brady"
p string_post[:author]
string_post[:likes] = 300
p string_post.keys
p string_post.values
p string_post
# Symbol Hash - Ideal
symbol_post = {
date: "6/10/16",
title: "About my Turtle",
author: "Tom Greene",
body: "I just saw my turtle surfing in the ocean!"
}
p symbol_post[:author]
symbol_post[:author] = "Sarah Brady"
p symbol_post[:author]
symbol_post[:likes] = 300
p symbol_post.keys
p symbol_post.values
p symbol_post