Task 3 – Using a Pure attribute
Refactor the following method by making it a pure function and marking it with the Pure
attribute:
public string GenerateEnemyCode(string enemyType, int level) { var code = enemyType.Substring(0, 3) + level.ToString(); return new string(code.OrderBy(c => c).ToArray()); }
If these tasks are easy, you might want to consider reading topics that are new to you first. If you have any questions or are not sure about the correct answers, don’t worry – next, we’ll dive into the concept of pure functions and side effects while using the characters from the previous chapter – Julia and Steve.
A week later, Julia called Steve and said that if he wanted to continue learning functional programming, he needed to understand the logic of pure functions and side effects.
Julia: Pure functions are functions that have deterministic output and no observable side...