From 080b998176b6ce1aacb15415c8a80f61109125c0 Mon Sep 17 00:00:00 2001 From: "dreddick.home2@gmail.com" Date: Thu, 5 Nov 2020 17:03:04 +0000 Subject: [PATCH] refactor UpdateQuality into switch statement --- go/gilded-rose.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/go/gilded-rose.go b/go/gilded-rose.go index fa7eb1ca..d819a3b1 100644 --- a/go/gilded-rose.go +++ b/go/gilded-rose.go @@ -84,22 +84,15 @@ func UpdateQualityStandard(item *Item) { func UpdateQuality(items []*Item) { for i := 0; i < len(items); i++ { - if items[i].name == "Sulfuras, Hand of Ragnaros" { - continue - } - - if items[i].name == "Aged Brie" { + switch name := items[i].name; name { + case "Sulfuras, Hand of Ragnaros": + case "Aged Brie": UpdateQualityBrie(items[i]) - continue - } - - if items[i].name == "Backstage passes to a TAFKAL80ETC concert" { + case "Backstage passes to a TAFKAL80ETC concert": UpdateQualityBackstagePasses(items[i]) - continue + default: + UpdateQualityStandard(items[i]) } - - UpdateQualityStandard(items[i]) - } }