What is the use of the yield
keyword in Julia and what does it do? I have seen it used a few times in Python and then in Julia but it seems to be used in very different contexts in Julia.
Asked
Active
Viewed 1,467 times
4

logankilpatrick
- 13,148
- 7
- 44
- 125
1 Answers
5
Unlike in Python, where the yield keyword function similar to the return keyword but for generators, the yield
keyword function in Julia is part of the tasks interface. From the docs:
yield()
Switch to the scheduler to allow another scheduled task to run. A task that calls this function is still runnable, and will be restarted immediately if there are no other runnable tasks.

logankilpatrick
- 13,148
- 7
- 44
- 125
-
6You may also want to note that it's just a function, not a keyword. – StefanKarpinski Mar 18 '20 at 16:41