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
  • 151,199
  • 17
  • 111
  • 216
Nicolas S.Xu
  • 12,570
  • 27
  • 76
  • 122

0 Answers0