問題:
I am trying to understand blocks and yield
and how they work in Ruby.我試圖瞭解塊和yield
以及它們在 Ruby 中的工作方式。
How is yield
used? yield
如何使用? Many of the Rails applications I've looked at use yield
in a weird way.我看過的許多 Rails 應用程序都以一種奇怪的方式使用了yield
。
Can someone explain to me or show me where to go to understand them?有人可以向我解釋或告訴我去哪裏理解他們嗎?
解決方案:
參考一: https://stackoom.com/question/Crmx參考二: Blocks and yields in Ruby