Update snippet descriptions

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-11-02 19:27:07 +02:00
parent c469b67f0b
commit a2cd6db3b0
22 changed files with 67 additions and 64 deletions

View File

@ -3,7 +3,7 @@ title: check_prop
tags: function,intermediate
---
Given a predicate function, `fn`, and a `prop` string, this curried function will then take an object to inspect by calling the property and passing it to the predicate.
Creates a function that will invoke a predicate function for the specified property on a given object.
- Return a `lambda` function that takes an object and applies the predicate function, `fn` to the specified property.
@ -15,6 +15,5 @@ def check_prop(fn, prop):
```py
check_age = check_prop(lambda x: x >= 18, 'age')
user = {'name': 'Mark', 'age': 18}
check_age(user) # True
```