Skip to main content

Practice · 3 of 3

Mini rule engine

CHALLENGE
Difficulty: advanced+25 XP

Implement class RuleEngine with private readonly List<(string Name, Func<Dictionary<string,int>, bool>)> _rules = new();, public void Add(string name, Func<Dictionary<string,int>, bool> pred) and public List<string> Evaluate(Dictionary<string,int> ctx) returning names of all passing rules in registration order. Prove closure capture over the context is by-reference at evaluation time.

Back to lesson: Practice: Delegate drills