+ 2

What is the diference between RETURN and YIELD?

15th Apr 2016, 11:16 PM
camelo
camelo - avatar
3 Answers
+ 4
I think the main difference between RETURN and YIELD is that RETURN only returns value once (after RETURN statement, the code will stop running) while YIELD is quite similar with RETURN but it returns value multiple times (depends on the number of your iterations). Try assign a yield function to a variable and return function to another one (use iteration for both func), you might understand the difference.
27th Jun 2016, 10:55 AM
Ade Kurniawan
Ade Kurniawan - avatar
+ 2
In short: yield is a keyword that is used like return, except the function will return a generator.
26th May 2016, 12:52 PM
James Flanders
+ 1
What does generator exactly means
26th Jun 2016, 6:33 PM
Riadh F
Riadh F - avatar