Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9284963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:02:08+00:00 2026-06-18T19:02:08+00:00

From within a Ruby script, verbosity can be tested with the value of the

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T19:02:09+00:00Added an answer on June 18, 2026 at 7:02 pm

    To see the real difference, you have to print some text on the $STDERR. I’ve made the following change on your example:

    ruby -W0 -e 'a=10;a=10;@foo;warn "hello"'
    

    Note that running the code with the W0 flag, nothing will appear in the terminal when you execute. Now, if you run with the W1, you will see the “error” message generated by the Kernel#warn:

    ruby -W1 -e 'a=10;a=10;@foo;warn "hello"'
    

    And finally, the W2 will show the error and the warnings generated by the interpreter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I export an environment variable from within a Ruby script to the
I have a Ruby script which downloads YouTube Insight reports for specific videos within
How do I tell from within a ruby script whether it has been run
I want to run a program from within my Ruby script, but I want
Does anyone have experience with running unit tests written in Ruby from within Maven.
From within a ruby script, what is the best way to check if a
I am trying to install ruby 1.9.2 from a ruby script using rvm which
I have a Ruby script that I'm running in PowerShell (via Rake) which contains
I would like to do something like this from a Ruby script, within a
I have a very simple ruby rack app which retrieves information from a webservice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.