Using if case
if case can be used as the opposite of
guard case. It is a great way
to unwrap and match data within a branch. In line with our previous
guard example. Obviously, we need an move function. Something that
allows us to say that an entity moved in a direction. Since our entities
enums, we need to return an updated entity.
return entity } print(move(Entity.Entry(type: .soldier, x: 10, y: 10, hp: 79), xd: 30, yd: 500)) // prints: Entry(main.Entity.EntityType.soldier, 40, 510, 79)