生成一个同时有symbol和string为键值的hash

使用到ActiveSupport::HashWithIndifferentAccess

rgb = ActiveSupport::HashWithIndifferentAccess.new

rgb[:black] = '#000000'
rgb[:black]  # => '#000000'
rgb['black'] # => '#000000'

rgb['white'] = '#FFFFFF'
rgb[:white]  # => '#FFFFFF'
rgb['white'] # => '#FFFFFF'

你可能感兴趣的:(生成一个同时有symbol和string为键值的hash)