Hello everyone,
I’m a newbie to Elixir and reading the book “Learn Functional Programming with Elixir”.
In the book this stuctured was defined:
defmodule DungeonCrawl.Character do
defstruct name: nil,
description: nil,
hit_points: 0,
max_hit_points: 0,
attack_description: nil,
damage_range: nil
end
and initialized here:
defmodule DungeonCrawl.Heroes do
alias DungeonCrawl.Character
def all do
[
%Character{
name: "Knight",
decription: "Knight has strong defense and consistent damage.",
hitpoints: 18,
max_hit_points: 18,
damage_range: 4..5,
attack_description: "a sword"
},
]
end
end
Without the Heroes module, compile is ok. With the Heroes module, I get this error:
== Compilation error in file lib/dungeon_crawl/heroes.ex ==
** (KeyError) key :decription not found
(dungeon_crawl 0.1.0) expanding struct: DungeonCrawl.Character.__struct__/1
(dungeon_crawl 0.1.0) lib/dungeon_crawl/heroes.ex:6: DungeonCrawl.Heroes.all/0
(elixir 1.11.1) lib/kernel/parallel_compiler.ex:314: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7
I’ve been trying to fix this forever. The code seems ok. Please help.