Open dvas0004 opened 4 years ago
old_list = [{ 'fieldToUpdate': 'oldValue' }] new_list = list( map( lambda entry: entry.update({'fieldToUpdate': 'newValue'}) or entry, old_list) ) # new_list is now: [{'fieldToUpdate': 'newValue'}]
The above code snippet makes use of the fact that the "update" method of a standard python dict returns "None" - hence you can see the "or" being used to returned the newly updated entry
The above code snippet makes use of the fact that the "update" method of a standard python dict returns "None" - hence you can see the "or" being used to returned the newly updated entry