دنبال کننده ها

۱۳۹۶ آبان ۱۱, پنجشنبه

Meaning of a python statement with "next( c for c in l if )"

[ad_1]



when porting some python code into PHP I ran into problems with the following piece of code:



def getOrAdd(self, config):
h = config.hashCodeForConfigSet()
l = self.configLookup.get(h, None)
if l is not None:
r = next((c for c in l if config.equalsForConfigSet(c)), None)
if r is not None:
return r
if l is None:
l = [config]
self.configLookup[h] = l
else:
l.append(config)
return config


I cannot figure out, what the line



r = next((c for c in l if config.equalsForConfigSet(c)), None)


does mean.



Can anybody explain me the sense of this statement, please?



Thank you in advance!




[ad_2]

لینک منبع