如何以双精度传递哈希
How to pass a hash in double
有一种情况,我有多个具有相同值的键,为了避免重复,我做了类似下面的事情
sports = [:cricket,:football,:basketball,:baseball,:rugby,:swimming,:table_tennis,:soccer,:karate]
final_hash = Hash.new
sports.each{|d| final_hash[d] = OpenStruct.new(categories: [], count: [], user_hash: {}, sport_count: [], options: {}, period: "",stat_type: "" ) }
现在我想在我的双块中传递这个散列,但每当我这样做时我都会得到一个错误
context 'For users details Page' do
it 'should give the data' do
###now I want to pass the hash SO can anyone guide me how can I do it
presenter = double(UserPresenter, id: 1, sector_name: nil, final_hash)
end
end
正如@engineersmnky 所建议的那样,在哈希上使用双 splat 运算符 (**hash) 对我有用。
有一种情况,我有多个具有相同值的键,为了避免重复,我做了类似下面的事情
sports = [:cricket,:football,:basketball,:baseball,:rugby,:swimming,:table_tennis,:soccer,:karate]
final_hash = Hash.new
sports.each{|d| final_hash[d] = OpenStruct.new(categories: [], count: [], user_hash: {}, sport_count: [], options: {}, period: "",stat_type: "" ) }
现在我想在我的双块中传递这个散列,但每当我这样做时我都会得到一个错误
context 'For users details Page' do
it 'should give the data' do
###now I want to pass the hash SO can anyone guide me how can I do it
presenter = double(UserPresenter, id: 1, sector_name: nil, final_hash)
end
end
正如@engineersmnky 所建议的那样,在哈希上使用双 splat 运算符 (**hash) 对我有用。