ruby - How does the command-line option "W1" differ from "W0"? -
from within ruby script, verbosity can tested value of $verbose
global variable, can have 3 states:
nil in case verbosity level “0” (silence) false level “1” (medium); default true level “2” (verbose); verbose mode.
i started play code understand 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: perchance useless utilize of variable in void context -e:1: warning: instance variable @foo not initialized @ubuntu:~$
but not understand difference between w1
, w0
. help me understand difference?
to see real difference, have print text on $stderr. i've made next alter on example:
ruby -w0 -e 'a=10;a=10;@foo;warn "hello"'
note running code w0
flag, nil appear in terminal when execute. now, if run w1
, see "error" message generated kernel#warn
:
ruby -w1 -e 'a=10;a=10;@foo;warn "hello"'
and finally, w2
show error , warnings generated interpreter.
ruby ruby-1.9.3
No comments:
Post a Comment