Ad

Ruby - ARGV.empty? ModuleName Else Code Here End Always Returns ModuleName

- 1 answer

probably stupid question

I have some code:

if ARGV.empty?
  ModuleName
else
  #Awesome Code Here
end

But no matter what, the ModuleName module is always evaluated. Is there something that I am missing?

Ad

Answer

I think the module is actually evaluated when you require it, not because the ModuleName line is reached.

Example:

in a foo.rb file:

class Foo
   puts "foo"
end

And then in irb:

1.8.7 :001 > require 'foo'
foo
 => true 
Ad
source: stackoverflow.com
Ad