Wiki

Changes between Version 3 and Version 4 of ConditionalExpr

Show
Ignore:
Timestamp:
02/01/14 11:39:03 (4 years ago)
Author:
hopscc
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ConditionalExpr

    v3 v4  
    1212   * blank strings and empty collections are true (non nil) - must check .length for strings and .count for collections for checking non empty. 
    1313 
    14 nilable objects (e.g nilable boolean, nilable int) test true if both non nil and non nil object is 'true' (non false or non zero) 
     14nilable types (e.g nilable boolean, nilable int) test true if both non nil and the non nil object is 'true' (non false or non zero)[[BR]] 
     15 
     16A nilable Object and nilable String (Object?, String? ) tests true if the instance is non-nil (no subsequent truth test beyond that) 
    1517 
    1618== Examples == 
     
    4345else 
    4446    print 's is nil' 
     47assert s  # succeeds if s is not nil 
     48 
     49 
     50s1 as String ='...'   # non-nilable string with or without (0 length) value  
     51if s.length 
     52    print 's not empty' 
     53else 
     54    print 's is length 0' 
     55assert s1        # always succeeds - non nilable (warning) 
     56assert s1.length # succeeds if s1 is not empty ( > length 0) 
     57 
    4558 
    4659l = []         # empty list 
     
    5770nb = nil 
    5871assert nb      # also fails variable is nil 
    59   
     72 
     73#nilable Object 
     74shouldBeFalse as Object? = false  # bool value typed as nilable Anything 
     75assert shouldBeFalse == false # ok 
     76shouldBeTrue0 = not shouldBeFalse # tests against nil only  
     77assert shouldBeTrue0 == true  # fails assertion 
     78shouldBeTrue = not (shouldBeFalse to bool)   
     79assert shouldBeTrue == true  # ok 
    6080}}} 
    6181