From: maven apache Date: 2012-02-12T22:49:11+09:00 Subject: Re: the ruby syntax --0023544707900c0c7304b8c49f0b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2012/2/12 Bartosz Dziewo=C5=84ski > When a hash is the last argument to a method, you can skip its open- > and close-braces. > > So this: > IO.new("data.txt", mode: 'w:UTF-16LE', cr_newline: true) > Is the same as this: > IO.new("data.txt", {mode: 'w:UTF-16LE', cr_newline: true}) > But in the ruby document:http://www.ruby-doc.org/docs/ProgrammingRuby/ Definiation of a hash should like this: {'key'=3D>'value'.....} Now in the IO.new exmaple,it is written as {key:value}. Is the ':' symbol same as '=3D>'?? I do not find it is methioned in any document. > The first argument is the "data.txt" string, the second argument is > the entire hash. The method then checks the type of second argument, > and in this case - since it's a hash - it considers it to be the opt > variable, with mode taking default value. > > -- Matma Rex > > --0023544707900c0c7304b8c49f0b--