锁定老帖子 主题:nil的疑惑
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-02-28
令:a = {:x => 1}
既然:a[:y] == nil 则应有:a == {:x => 1, :y => nil} 但上面的逻辑不成立。 如果a[:y]的结果是undefined,而不是nil,那么说得过去。 |
|
返回顶楼 | |
发表时间:2007-02-28
dcaoyuan 写道 令:a = {:x => 1}
既然:a[:y] == nil 则应有:a == {:x => 1, :y => nil} 但上面的逻辑不成立。 如果a[:y]的结果是undefined,而不是nil,那么说得过去。 if a[:y] should be "undefined", what should params[:a] be? still "undefined". you still have the same problem. the only difference is that you give nil a nickname "undefined" |
|
返回顶楼 | |
发表时间:2007-02-28
In case of none params[:a] given, params[:a] should also be "undefined", so, the default_options.merge(user_options) will work properly, it can still give out a result:
{:a => 1, :b => 1}. Actually it's Ruby who seems to give nil a nickname "undefined". |
|
返回顶楼 | |