From 04cfa5d408aded92ea14e8a5f39456685438dfe7 Mon Sep 17 00:00:00 2001 From: Paul Fortin Date: Tue, 4 Jul 2017 22:30:40 -0400 Subject: [PATCH] Update index.md I was thinking we wanted examples not just links to another Q&A site. --- chapters/maps/presence/index.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/chapters/maps/presence/index.md b/chapters/maps/presence/index.md index d0ec275..7b34ea2 100644 --- a/chapters/maps/presence/index.md +++ b/chapters/maps/presence/index.md @@ -2,5 +2,10 @@ title: Testing for the Presence of a Key in a Map question: How do I determine if a map contains a given key? --- - -http://stackoverflow.com/questions/2050391/how-to-check-if-a-map-contains-a-key-in-go +``` + if val, ok := dict["foo"]; ok { + //key found - do somehting + } else { + //Key does not exist + } +```