From within a Ruby script, verbosity can be tested with the value of the $VERBOSE
global variable, which can have three states:
nil in case verbosity level was “0” (silence)
false for level “1” (medium); this is the default
true for level “2” (verbose); this is verbose mode.
I started to play with my code to understand the difference between them:
@ubuntu:~$ ruby -W0 -e 'a=10;a=10;@foo'
@ubuntu:~$ ruby -W1 -e 'a=10;a=10;@foo'
@ubuntu:~$ ruby -W2 -e 'a=10;a=10;@foo'
-e:1: warning: possibly useless use of a variable in void context
-e:1: warning: instance variable @foo not initialized
@ubuntu:~$
But really could not understand what the difference between W1
and W0
. Could anyone help me to understand the difference?