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 figure out what $_[0] is.
It is being assigned to a variable in the code, and it is definitely not a command-line argument because I wrote code to test that and it failed.
So, can anyone say what the significance of it is?
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