Question

Can any body tell how the below three options differs from each other in Ruby?

Part-I

  • --verbose
  • -v
  • -w

Part-II

  • -n
  • -p

All are doing the same job which is verbose mode ON. But logically how are they differs from each other?

Thanks,

Was it helpful?

Solution

-v is just a shorter way of writing --verbose, so they are the same thing. -w turns on warnings, see http://www.caliban.org/ruby/rubyguide.shtml#warnings for more info about those.

Part 2:

-n and -p are not related to verbosity. They just loop your ruby script.

Run the following from your terminal:

ruby -n -e "puts 'hello world'"

Now press the enter key a few times. You should see:

hello world

hello world

hello world

Now do the same for -p:

ruby -p -e "puts 'hello world'"

This just repeats what you typed before pressing enter.

asdf
hello world
asdf

hello world

asdfs
hello world
asdfs
34644
hello world
34644
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top