Task 3 – Currying permission checks for game features
Curry this function so that it can first accept a userRole
and then return another function that takes a feature
, determining whether the specified role has access to it:
public bool CheckGameFeatureAccess(UserRoles userRole, GameFeatures feature) { return _gameFeatureManager.HasAccess(userRole, feature); }
You might think these methods are already optimal, but their simplicity is intentional. These focused tasks let you practice functional programming without distractions. As always, these tasks are just for your self-assessment, and you’re not supposed to solve them easily. So, don’t worry if you have any difficulties with them, and just proceed with reading the chapter. By its end, you’ll tackle these challenges like a pro. Keep that in mind, and I hope you have a happy coding experience!