1

Yield seems to be neither object nor method. What is it? How does it access the block that is passed as an argument to the method?

sawa
  • 165,429
  • 45
  • 277
  • 381
Kamesh
  • 1,435
  • 1
  • 14
  • 27

1 Answers1

5

yield is a keyword, just like while or end or return.

"How" it accesses the block is not really interesting, no more than "how" a return keyword delivers a value to the calling context, or "how" an end keyword closes a block - unless you want to dive into development of Ruby interpreter itself. The important bit for a Ruby programmer is just that that's what it does.

Amadan
  • 191,408
  • 23
  • 240
  • 301