On Dec 3, 1:13 am, Wolfgang Nádasi-Donner <ed.oda... / wonado.de> wrote: > Jordan Callicoat wrote: > > On Dec 2, 5:03 pm, Wolfgang N�äasi-Donner <ed.oda... / wonado.de> wrote: > >> It's unclear for me what this means. I would expect that the Generator > >> object delivers (yields) values by requirement through > >> "Generator#current" or "Generator#next", but what should be yielded to > >> an already existing Generator object? > > It's for passing items *into* the generator's queue when the generator > > is created with the block form of Generator#new rather than from an > > existing enumerable. Example... > > I see - the confusion came from the usual meaning of yield: call a block > and deliver objects to it. Here it is used from a block into a method. Yes... it really should be spelled differently. The idea is "send this item into the generator queue, so that the generator yields it (normal meaning) on the next iteration"...but it is confusing to have it named yield. > btw. - at least in "PickAxe" the word "yield" it marked as a reserved > word. Object attributes can share the same name as reserved words since they live in the namespace of the caller. Example... class Control def if(cond, yes, no) # 'if' is a reserved keyword if instance_eval(cond) then yes else no end end end Control.new.if("5>4", "ok", "broken") # => "ok" > Wolfgang Nádasi-Donner > -- > Posted viahttp://www.ruby-forum.com/. Regards, Jordan