-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlists.rb
72 lines (48 loc) · 1.94 KB
/
lists.rb
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# You should definitely know:
# How would you access the "b" in the following array?
# letters = ["a", "b", "c"]
# What are the two ways you can add "d" on to the end of the following array?
# letters = ["a", "b", "c"]
# Which is the hash and which is the array?
# ["a", "b", "c"] {"a" => 1, "b" => 2, "c" => 3}
# How would you access the 2 in the following hash?
# letter_hash = {"a" => 1, "b" => 2, "c" => 3}
# How would you add the key-value pair of "d" => 4 to the following hash?
# letter_hash = {"a" => 1, "b" => 2, "c" => 3}
# Arrays are organized by ____________, hashes are organized by _____________
# How would you access the "z" in the following array?
# letters = ["a", "b", ["x", "y", "z"]]
# How would you access the "26" in the following hash?
# letter_hash = {"a" => 1, "b" => {"x" => 24, "y" => 25, "z" => 26 }, "c" => 3}
# (optional): What am I doing wrong if I'm trying to access "x"
# letters = ["a", "b", ["x", "y", "z"]]
# letters[2[0]]
# For the following lists, choose whether an array or a hash is more appropriate?
# 1. A list that you're going to be accessing by descriptive keywords
# 2. A list that you're going to be accessing by order
# 3. A list that will contain an unknown number of elements
# 4. A list of student names and descriptors
# 5. A list of students
# 6. A chronological list of events
# 7. A list of customer information
# Good to know:
# staff = [
# {
# "name" =>
# { "first" => "Arjun", "last" => "Venkataswamy" },
# "address" =>
# {"neighborhood" => "Wicker Park", "zip" => 60622}
# },
# {
# "name" =>
# { "first" => "Raghu", "last" => "Betina" },
# "address" =>
# {"neighborhood" => "Lincoln Park", "zip" => 60614}
# },
# {
# "name" =>
# { "first" => "Jeff", "last" => "Cohen" },
# "address" =>
# {"neighborhood" => "Skokie", "zip" => 60077}
# }
# ]