Ruby global variables, legal use

I have never seen global variables used in any Ruby code. I understand that their use is unsatisfying in languages, but they seem to be useless in Ruby. Can anyone point to properly designed code that uses them?

If I am right and they are redundant / historical, why are they stored in 1.9?

To be clear, I do not mean the variables that Ruby sets up for you as $"well $stdin. I mean use in one native code.

+3
source share
2 answers

The only time I see it in decent code is a magazine.

$log = Logger.new('foo.log', 'daily')

The constant is likely to be fine, but it somehow strange calls the invocation methods on the constant.

+2

Ruby. CLASSPATH jruby ...

, ( ).

, Ruby.

+1

Source: https://habr.com/ru/post/1790808/


All Articles