Top "Yield" questions

yield is (1) a keyword that facilitates creation of generator functions, (2) a Ruby statement to transfer control from one coroutine to another, (3) a Java statement used to yield a value from a switch expression.

Equivalent C++ to Python generator pattern

I've got some example Python code that I need to mimic in C++. I do not require any specific solution (…

c++ python generator yield coroutine
TypeError: 'generator' object has no attribute '__getitem__'

I have written a generating function that should return a dictionary. however when I try to print a field I …

python python-2.7 dictionary yield yield-return
yield break in Python

According to answer to this question, yield break in C# is equivalent to return in Python. In the normal case, …

python generator yield
When NOT to use yield (return)

This question already has an answer here: Is there ever a reason to not use 'yield return' when returning an …

c# .net yield yield-return
Unity - IEnumerator's yield return null

I'm currently trying to understand IEnumerator & Coroutine within the context of Unity and am not too confident on what …

c# unity3d yield coroutine ienumerator
How to Pythonically yield all values from a list?

Suppose I have a list that I wish not to return but to yield values from. What is the most …

python generator yield
Ruby: Proc#call vs yield

What are the behavioural differences between the following two implementations in Ruby of the thrice method? module WithYield def self.…

ruby yield
Return all enumerables with yield return at once; without looping through

I have the following function to get validation errors for a card. My question relates to dealing with GetErrors. Both …

c# ienumerable yield yield-return
Rails check if yield :area is defined in content_for

I want to do a conditional rendering at the layout level based on the actual template has defined content_for(:…

ruby-on-rails layout yield
Is there a Java equivalent to C#'s 'yield' keyword?

I know there is no direct equivalent in Java itself, but perhaps a third party? It is really convenient. Currently …

java yield yield-return