2012/2/12 Bartosz Dziewoski <matma.rex / gmail.com>

> 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'=>'value'.....}

Now in the IO.new exmaple,it is written as {key:value}.  Is the ':' symbol
same as '=>'?? 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
>
>