On Sun, Dec 07, 2008 at 04:49:46PM +0900, Gilman G. wrote:
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
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
expression. For instance, at my tcsh console one might see this:
irb(main):001:0> foo = 'first'
irb(main):002:0> bar = 'second'
irb(main):003:0> print foo, ' and ', bar, "\n"
first and second
These return value indicators are useful for figuring out exactly what a
given expression does when writing code – you may have an editor open
which you are writing a program and, in another terminal emulator
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.
=> 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
sequence, nothing springs immediately to mind.