Ruby has many special variables with
that have special meaning and,
these are global variables. Few of them are:
$/ - Input record separator. Default: “\n”. Used by gets, each_line while reading inputs. Used to specify the input row or record separator.
$\ - Output record separator. Default: nil. Used by print and IO#write.
$, - Default separator for Array#join and print. Default: nil.
$; - Default separator for String#split. Default: nil.
These are not frequently used in ruby programs. They were commonly used in oneliner scripts.
Being global, these variables cannot be safely overridden or changed in multi-threaded environments, since they are thread-local.
Ruby 2.7 onwards these 4 variables are
so setting or overriding the default values
for special variables with
$\ will throw a deprecated warning.
$; = " " > warning: `$;' is deprecated $\ = " " > warning: `$\' is deprecated $; = " " > warning: `$;' is deprecated $/ = " " > warning: `$/' is deprecated