enumerator - How enum#feed works in ruby? -


enum#feed

sets value returned next yield inside e.if value not set, yield returns nil.this value cleared after being yielded.

i tried 1 example not 1 think understand #feed method.

a = [1,2,3,4].to_enum p a.next #=> 1 a.feed 'foo' p a.next #=> 2 , expected here 'foo' 

can give me example understand how #feed method works?

based on documentation linked to, it's enumerable object in question decide feed call. in case, default behavior ignore it. if write own custom enumerable class, accept , treat will.

i have never seen feed used, again, it's sort of thing that's put there occasions when might need it. can't think of use thing @ all, honest.

you'll have test various things support, i'd surprised if find objects use presume.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -