mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
network/library: fix Util.first to properly honor predicate
This commit is contained in:
parent
ddc1493a6f
commit
b085b9be67
1 changed files with 2 additions and 3 deletions
|
|
@ -56,9 +56,8 @@ class Util:
|
|||
@staticmethod
|
||||
def first(iterable, default = None, pred = None):
|
||||
for v in iterable:
|
||||
if pred is not None and pred(v):
|
||||
continue
|
||||
return v
|
||||
if pred is None or pred(v):
|
||||
return v
|
||||
return default
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue