1
def minimize():
    current = yield
    while True:
        value = yield current # what is this????
        current = min(value, current)

I got this piece of code from here. Here is the quote:

" The generator function receives the value passed to the send function as the result of the corresponding yield expression."

note: it says yeild expression, which mean the whole "yield current" thing. Is my understanding correct? If so, why not just use "yield", removing "current" from the expression??

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Nicolas S.Xu
  • 13,794
  • 31
  • 84
  • 129

0 Answers0