Typecasting HashWithIndifferentAccess

I want to typecast an object of HashWithIndifferentAccess (params) to
Hash.
Whats the way of doing this (except each?)

Thanks in advance.

Hi,

On 12/3/05, Onur T. [email protected] wrote:

I want to typecast an object of HashWithIndifferentAccess (params) to Hash.
Whats the way of doing this (except each?)

There is no typecasting in Ruby. The Hash.[] method returns a new
Hash from the object you pass in:

params[:action] # => ‘index’
params.class # => HashWithIndifferentAccess

strict_params = Hash[params]

strict_params.class # => Hash
strict_params[:action] # => nil
strict_params[‘action’] # => ‘index’

Sam