Reputation: 508
In the Ruby string :
"${0} ${1} ${2:hello}"
is ${i}
the ith argument in the command that called this particular file.
Tried searching the web for "Ruby ${0}" however the search engines don't like non-alphanumeric characters.
Consulted a Ruby book which says #{...} will substitute the results of the code in the braces, however this does not mention ${...}, is this a special syntax to substitute argvalues into a string, thanks very much,
Joel
Upvotes: 0
Views: 158
Reputation: 27667
As mentioned above ${0}
will do nothing special, $0
gives the name of the script, $1
gives the first match from a regular expression.
To interpolate a command line argument you'd normally do this:
puts "first argument = #{ARGV[0]}"
However, ARGV is also aliased as $*
so you could also write
puts "first argument = #{$*[0]}"
Perhaps that's where the confusion arose?
Upvotes: 4