I want to typecast an object of HashWithIndifferentAccess (params) to
Hash.
Whats the way of doing this (except each?)
Thanks in advance.
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs