[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Newbie syntax questions

brian.kejser

9/11/2006 3:56:00 PM

Hi

In the 'test/unit' library the file unit.rb contains the following code.

module Test
module Unit
def self.run=(flag)
@run = flag
end

def self.run?
@run ||= false
end
end
end

at_exit do
unless $! || Test::Unit.run?
exit Test::Unit::AutoRunner.run($0 != "-e" && $0)
end
end

Could someone please explain the following:

1. Why is there an equals sign in the code "def self.run=(flag)" and what
does it do?

2. Why is there an equals sign in the code "@run ||= false" and what does
it do?

3. Why is the 'run' member of the 'Unit' module accessible on the line "
unless $! || Test::Unit.run?"? Doesn't this require the attr_reader syntax
in the module?

5. What does "$0 != "-e" && $0" mean and do?

Thanks