lambda
function that takes an object and applies the predicate function, fn
to the specified property.def check_prop(fn, prop): return lambda obj: fn(obj[prop])
check_age = check_prop(lambda x: x >= 18, 'age') user = {'name': 'Mark', 'age': 18} check_age(user) # True
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️