What are those pipe symbols for in Ruby?

前端 未结 7 754
一个人的身影
一个人的身影 2020-11-30 01:57

What are the pipe symbols for in Ruby?

I\'m learning Ruby and RoR, coming from a PHP and Java background, but I keep coming across code like this:

de         


        
7条回答
  •  无人及你
    2020-11-30 01:57

    The code from the do to the end defines a Ruby block. The word format is a parameter to the block. The block is passed along with the method call, and the called method can yield values to the block.

    See any text on Ruby for details, this is a core feature of Ruby that you will see all the time.

提交回复
热议问题