classHashWithIndifferentAccess<Hashdefinitialize(constructor={})ifconstructor.is_a?(Hash)super()update(constructor)elsesuper(constructor)endendalias_method:hash_writer,:[]=def[]=(key,value)result=hash_writer(key,convert_value(value))puts"result class is #{result.class}"resultenddefconvert_value(value,options={})ifvalue.is_a?HashHashWithIndifferentAccess.new(value)elsevalueendendend
If run this is code that it return incorrect data:
I see what method HashWithIndifferentAccess#[]= return Hash object but should HashWithIndifferentAccess.
This is a bug?
No. In ruby, assignment always returns the right hand side, it doesn't matter what the assignment method returns. So temp_hash is the argument you passed to HashWithIndifferentAccess#[]= (a plain hash). But ps[:test] should be a HashWithIndifferentAccess.
I see what method HashWithIndifferentAccess#[]= return Hash object but should HashWithIndifferentAccess.
This is a bug?
No. In ruby, assignment always returns the right hand side, it doesn't matter what the assignment method returns. So temp_hash is the argument you passed to HashWithIndifferentAccess#[]= (a plain hash). But ps[:test] should be a HashWithIndifferentAccess.
Hello Jeremy Evans, thank you. Now all fit in the head.
Close please this issue. I don't find close button.