开发者

Can't understand yield

In some project i met this code:

erb = yield.src

I can't understan开发者_C百科d what the src method is doing and how it's possible to chain to yield method.

Thanks


As far as I understand yield would return an object which has the instance method src defined on it

something like this

def foo
  p yield.class
end

foo do 
 1
end  

This will print Fixnum

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜