刚刚在 RoR 3.2.8 中遇到以下代码。这是否意味着 self 属于合并函数或类?
结果.合并( 简介:自我)
任何帮助将不胜感激
Depends on the context. ie. where you found this line of code.
class Profile
def foo
results.merge(profile: self)
end
end
p = Profile.new
p.foo
In this case "self" will be referring to the object "p", which is the current object in the context where "self" is used.
它正在合并当前对象 - 配置文件到结果