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.

Scala - can yield be used multiple times with a for loop?

An example: val l = List(1,2,3) val t = List(-1,-2,-3) Can I do something like this? for (i <…

scala yield cartesian-product
Trying to understand generators / yield in node.js - what executes the asynchronous function?

Node.js now has generators. My understanding is that generators can be used to write code that appears to be …

node.js generator yield
Rails 3: yield/content_for with some default value?

Is there any way to detect if #content_for was actually applied to a yield scope in Rails? A classic …

ruby-on-rails ruby yield
What is the return type hint of a generator function?

I'm trying to write a :rtype: type hint for a generator function. What is the type it returns? For example, …

python python-2.7 generator yield type-hinting
Passing multiple code blocks as arguments in Ruby

I have a method which takes a code block. def opportunity @opportunities += 1 if yield @performances +=1 end end and I call …

ruby yield
Behavior of sched_yield

I have few questions about the sched_yield function because I'm seeing that it is not functioning as intended in …

multithreading linux-kernel yield scheduler
How does Ruby on Rails use yield for layouts?

yield is used to call a block. How does this work in Rails where yield is used for layouts? -# …

ruby-on-rails ruby methods block yield
Can I yield from an inner function?

With ES6 generators, I see code like this: var trivialGenerator = function *(array) { var i,item; for(var i=0; i < …

javascript for-loop generator yield ecmascript-6
Yield in a recursive function

I am trying to do something to all the files under a given path. I don't want to collect all …

python recursion iterator directory-structure yield
Python 3.x: Test if generator has elements remaining

When I use a generator in a for loop, it seems to "know", when there are no more elements yielded. …

python-3.x iteration generator yield next