I am a Java developer, and I have been given Ruby code to understand and later to work on.
I went through the Ruby tutorials on tutorialspoint.com but I can\'t figur
It's one of the magic variables.
$_
holds value of the last line read from standard input. $_[0]
is, therefore, first symbol of that string.
See English.rb for more magic variables
# The last line read by <tt>Kernel.gets</tt> or
# <tt>Kernel.readline</tt>. Many string-related functions in the
# +Kernel+ module operate on <tt>$_</tt> by default. The variable is
# local to the current scope. Thread local.
alias $LAST_READ_LINE $_
$_
- string last read by gets
[0]
is of course, indexing into that string.
http://www.rubyist.net/~slagell/ruby/globalvars.html