Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
my_dict = { "hello" => 13,
|
||||
"world" => 31,
|
||||
"!" => 71 }
|
||||
|
||||
# iterating over key-value pairs:
|
||||
my_dict.each {|key, value| puts "key = #{key}, value = #{value}"}
|
||||
# or
|
||||
my_dict.each_pair {|key, value| puts "key = #{key}, value = #{value}"}
|
||||
|
||||
# iterating over keys:
|
||||
my_dict.each_key {|key| puts "key = #{key}"}
|
||||
|
||||
# iterating over values:
|
||||
my_dict.each_value {|value| puts "value =#{value}"}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
for key, value in my_dict
|
||||
puts "key = #{key}, value = #{value}"
|
||||
end
|
||||
|
||||
for key in my_dict.keys
|
||||
puts "key = #{key}"
|
||||
end
|
||||
|
||||
for value in my_dict.values
|
||||
puts "value = #{value}"
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue