-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnestedhashesex.rb
37 lines (33 loc) · 1.13 KB
/
nestedhashesex.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
# flash = { success: "It worked", danger: "It failed." }
# flash.each do |key, value|
# puts "Key #{key.inspect} has value #{value.inspect}"
# end
#
# h2 = { name: "Michael Hartl", email: "[email protected]" }
#
#
# nested hashes
# params = {} # Define a hash called 'params' (short for 'parameters').
# => {}
# >> params[:user] = { name: "Michael Hartl", email: "[email protected]" }
# => {:name=>"Michael Hartl", :email=>"[email protected]"}
# >> params
# => {:user=>{:name=>"Michael Hartl", :email=>"[email protected]"}}
# >> params[:user][:email]
# => "[email protected]"
# number = { one: "uno", two: "dos", three: "tres" }
# number.each do |key, value|
# puts "#{key} in spanish is #{value}"
# end
=begin
# person1 = { first:"Joe", last:"Zoo"}
# person2 = { first:"Magdy", last:"Reepo"}
# person3 = { first:"Tim", last:"Itsy"}
# params = {:father=>person1, :mother=>person2, :child=>person3 }
# puts params[:father], params[:mother], params[:child]
=end
# perdetails = { name: "Otis", email: "[email protected]", ranstring: "shhhhsrrrhhh"}
# puts perdetails
h1 = {"a" => 1, "b" => 444}
h2 = {"b" => 222, "c" => 444}
h1.merge(h2)