Exception: InvalidNackError

Inherits:
ArgumentError
  • Object
show all
Defined in:
lib/carat/nack.rb

Overview

NackClass

The NackClass is is like the NilClass except one step down. Nack is never used to to mean nothingness or emptiness. The Nack class is only used to report something is “a miss” w/o the system raising an Exception. It’s a mechanism for lazy error evaluation.

Usage

def scalar( x )
  if x.kind_of?(Enumerable)
    return nack(ArgumentError, "Value must not be enumerable")
  end
  x
end

a = scaler( 1 )            #=> 1
b = scaler( [1,2] )        #=> nack
b.first                    #=> ArgumentError (previous)

a = nail scaler( 1 )       #=> 1
b = nail scaler( [1,2] )   #=> ArgumentError

TODO

  • I beleive this class has even more potential yet. It would be interesting to see if a catch/try correction facility could be built into it too.

Author(s)

  • Thomas Sawyer

Ruby License Copyright ©2004 Thomas Sawyer

History

  • 2005.04.11 Passed basic test.