a ? ? b # => a.typical_zero? ? b : a
def T # typical_zero?
self == T .typical_zero
def T.typical_zero
nil
if (a) # => if (! a.logical_zero?)
def T # logical_zero?
false
def Nil # logical_zero?
true
a || b # => a.semantic_zero? ? b : a
def T # semantic_zero?
{% if T .respond_to?(:semantic_zero ) % }
self == T .semantic_zero
{% else % }
true
Enumerable (T )# sum # => sum Reflect(T).first.additional_zero
Enumerable (T )# multi # => multi Reflect(T).first.multiplicative_zero
def String # logical_zero? = false
def String.semantic_zero = " "
def String.additional_zero = " "
def String.multiplicative_zero = " "
" " ? ? " no input" # => "" (due to typical zero)
" " || " no name" # => "no name" (due to semantic zero)
if " " # => true (due to logical_zero?)
def Bool # logical_zero? = self
def Bool.semantic_zero = false
def Bool.additional_zero = false
def Bool.multiplicative_zero = true
if false # => false
[false , true ].sum # => true
[false , true ].multi # => false
user class (Not Empty List)
def Array (T )# semantic_zero? = false
def NEL (T )# semantic_zero? = empty?
Array (Int32 ).new || [1 ] # => []
NEL (Int32 ).new || [1 ] # => [1]
if NEL (Int32 ).new # => false