From: "David A. Black" Date: 2009-11-21T21:14:17+09:00 Subject: Re: confuse about initialize hash Hi -- On Sat, 21 Nov 2009, vadivelan .K wrote: > Zhenning Guan wrote: >> def in(options ={} ) >> p options >> end >> >> in(:say => "somehting") # {:say => "something"} >> >> but under the hood of it, doesn't that process equivalent to >> ------- >> options = {} >> options = :say => "something" >> ------- >> or >> ------ >> options = :say => "something" >> ------ >> ??? none of this can compiler. >> silly question, hope someone help. > > Hey Zhenning Guan, > > Hope the following sample will help you, > > def in(options) > p options.class > end > in(:say => 'some_value') > > the type of argument passed to any method resembles inside the method, > if you send hash it shows the class as 'Hash'. No need to initialize > hash or anything in ruby script. It will assign automatically according > to the values. Have you tried actually running your example? :-) David -- THE COMPLEAT RUBYIST, Ruby training with Black/Brown/McAnally! January 22-23, Tampa, Florida Info and registration at http://www.thecompleatrubyist.com -------------------------------------- My new job: http://tinyurl.com/yfpn9hz