Interactive Lesson:

Interactive Test Case

As we gain further experience, the list of spells we know grows and the number of paths we can take in-combat situations can grow to great lengths.

In order to handle this increasing complexity over time, it may be apt to change how we decide what to return from an if statement to a switch statement:

switch attackType {
  case "charge":
  case "bolt":
    fmt.Println("energy shield")
  case "stab":


The SelectSpell function takes in an enemy type which is of type string. We need to be able to decide quickly what spell to use with a switch statement.

  • When the type is rock - SelectSpell should return WaterBolt
  • When the type is water - SelectSpell should return ElectroBolt
  • When the type is ghost - SelectSpell should return ArcaneExplosion

Additional Scrolls of wisdom