所以我已经浏览过 Traiblazer 和 Reform 文档,我经常看到这种代码
class AlbumForm < Reform::Form
collection :songs, populate_if_empty: :populate_songs! do
property :name
end
def populate_songs!(fragment:, **)
Song.find_by(name: fragment["name"]) or Song.new
end
end
注意def populate_songs!(fragment:, **)
定义?
我很清楚**others
捕获所有其他关键字参数的双 splat 命名参数(如 )。但我从来没有见过**
一个人,没有名字。
所以我的两个问题是:
- **在上面的块中是什么意思?
- 为什么使用这种语法?