--huq684BweRXVnRxX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Dec 07, 2008 at 04:49:46PM +0900, Gilman Gunn wrote:
> Hi all,
> 
> I have a very basic question... what does "=>" mean? Two books I have
> looked at started using it without explaining and it is filtered in most
> searches.
> 
> My guess is that it has something to do with assignment but am not sure.
> 
> If anyone could shed some light on this it would be much appreciated.

In addition to being used to assign values in hashes, it is also how the
interactive Ruby interpreter (called "irb") shows the return value for an
expression.  For instance, at my tcsh console one might see this:

    ~> irb
    irb(main):001:0> foo = 'first'
    => "first"
    irb(main):002:0> bar = 'second'
    => "second"
    irb(main):003:0> print foo, ' and ', bar, "\n"
    first and second
    => nil

These return value indicators are useful for figuring out exactly what a
given expression does when writing code -- you may have an editor open in
which you are writing a program and, in another terminal emulator window,
have irb running so you can check how various expressions are evaluated
so you don't have to guess or constantly search through documentation to
be sure you're using expressions correctly.

The `=>` in this usage is not actually part of the code, though the `=>`
in hash assignments *is* part of the code (of course).

I hope that helps.  Other than those two uses of the `=>` character
sequence, nothing springs immediately to mind.

-- 
Chad Perrin [ content licensed OWL: http://owl.apotheon.org ]
Quoth Bjarne Stroustrup: "An ugly operation should have an ugly
syntactic form."

--huq684BweRXVnRxX
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)

iEYEARECAAYFAkk7j9kACgkQ9mn/Pj01uKV5zwCbBS+0di9AgAOZrrxZeK4WQCOB
CSwAn33FFB0PggEuPz8rWn7cho/tbFGh
ka
-----END PGP SIGNATURE-----

--huq684BweRXVnRxX--