@directions_to_the_right %{north: :east, east: :south, south: :west, west: :north}
def right(%ToyRobot.Position{facing: facing} = robot) do
%ToyRobot.Position{robot | facing: @directions_to_the_right[facing]}
end
This is the code. Normally in elixir we define structs like-
%Structname{key:value}
But here what is the significance of this @ and % after Struct’s name
Modules attributes (@directions_to_the_right in this case) are just conveniences. They are replaced at compile time (known as macro in other languages). They cannot be accessed once the module has been compiled.