In Ruby, what are the vertical lines?

后端 未结 4 2097
我寻月下人不归
我寻月下人不归 2020-12-20 23:23
1.upto(9) { |x| print x }

Why won\'t this work?

{ print x |x} }

What about y?

4条回答
  •  不知归路
    2020-12-21 00:22

    The vertical lines are use to denote parameters to the block. The block is the code enclosed within { }. This is really the syntax of the ruby block, parameters to the block and then the code.

提交回复
热议问题