each_with_key
This commit is contained in:
parent
319f521379
commit
de07d74856
2
blah.cr
2
blah.cr
@ -23,7 +23,7 @@ db.each do |car|
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Reaching all objects in the db with their key.
|
# Reaching all objects in the db with their key.
|
||||||
db.each_with_index do |car,key|
|
db.each_with_key do |car,key|
|
||||||
pp! car, key
|
pp! car, key
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -247,12 +247,12 @@ database.delete 0
|
|||||||
.QE
|
.QE
|
||||||
.
|
.
|
||||||
The function
|
The function
|
||||||
.FUNCTION_CALL each_with_index
|
.FUNCTION_CALL each_with_key
|
||||||
lists the entries with their keys.
|
lists the entries with their keys.
|
||||||
.
|
.
|
||||||
.QP
|
.QP
|
||||||
.SOURCE Ruby ps=10
|
.SOURCE Ruby ps=10
|
||||||
database.each_with_index do |value, key|
|
database.each_with_key do |value, key|
|
||||||
puts "#{key}: #{value}"
|
puts "#{key}: #{value}"
|
||||||
end
|
end
|
||||||
.SOURCE
|
.SOURCE
|
||||||
@ -586,7 +586,7 @@ end
|
|||||||
.QP
|
.QP
|
||||||
.SOURCE Ruby ps=10
|
.SOURCE Ruby ps=10
|
||||||
# List all the values in the database with their key
|
# List all the values in the database with their key
|
||||||
database.each_with_index do |value, key|
|
database.each_with_key do |value, key|
|
||||||
# ...
|
# ...
|
||||||
end
|
end
|
||||||
.SOURCE
|
.SOURCE
|
||||||
|
Loading…
Reference in New Issue
Block a user