Bake dates into snippets

This commit is contained in:
Isabelle Viktoria Maciohsek
2021-06-13 19:38:10 +03:00
parent 4c07c3ceb0
commit cbc78ee450
159 changed files with 1024 additions and 706 deletions

View File

@ -1,19 +1,21 @@
---
title: check_prop
tags: function,intermediate
---
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.
```py
def check_prop(fn, prop):
return lambda obj: fn(obj[prop])
```
```py
check_age = check_prop(lambda x: x >= 18, 'age')
user = {'name': 'Mark', 'age': 18}
check_age(user) # True
```
---
title: check_prop
tags: function,intermediate
firstSeen: 2020-01-02T16:49:25+02:00
lastUpdated: 2020-11-02T19:27:07+02:00
---
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.
```py
def check_prop(fn, prop):
return lambda obj: fn(obj[prop])
```
```py
check_age = check_prop(lambda x: x >= 18, 'age')
user = {'name': 'Mark', 'age': 18}
check_age(user) # True
```