在阅读一些 Ruby 代码时,我看到了这个:
create_table :talks do |t|
|variable|
这个符号是什么?那有什么作用?
此外,我在哪里可以找到这些特定主题的帮助,例如 | |
、#{}
等等?
最佳答案
这是一种为 block 定义参数的方法,类似于def methodname(arg1, arg2)
有一个很好的 block 解释 from Robert Sosinski
关于ruby - "do | |"在 Ruby 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4836820/