From de07d74856a02b7533f695e753e52c161b6ef0a3 Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Wed, 22 May 2024 00:39:33 +0200 Subject: [PATCH] each_with_key --- blah.cr | 2 +- graphs/graphs.ms | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/blah.cr b/blah.cr index 07d5c0b..2f742e6 100644 --- a/blah.cr +++ b/blah.cr @@ -23,7 +23,7 @@ db.each do |car| end # 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 end diff --git a/graphs/graphs.ms b/graphs/graphs.ms index b025502..2e13098 100644 --- a/graphs/graphs.ms +++ b/graphs/graphs.ms @@ -247,12 +247,12 @@ database.delete 0 .QE . The function -.FUNCTION_CALL each_with_index +.FUNCTION_CALL each_with_key lists the entries with their keys. . .QP .SOURCE Ruby ps=10 -database.each_with_index do |value, key| +database.each_with_key do |value, key| puts "#{key}: #{value}" end .SOURCE @@ -586,7 +586,7 @@ end .QP .SOURCE Ruby ps=10 # 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 .SOURCE