Changes between Version 3 and Version 4 of ConditionalExpr
- Timestamp:
- 02/01/14 11:39:03 (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ConditionalExpr
v3 v4 12 12 * blank strings and empty collections are true (non nil) - must check .length for strings and .count for collections for checking non empty. 13 13 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) 14 nilable 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 16 A nilable Object and nilable String (Object?, String? ) tests true if the instance is non-nil (no subsequent truth test beyond that) 15 17 16 18 == Examples == … … 43 45 else 44 46 print 's is nil' 47 assert s # succeeds if s is not nil 48 49 50 s1 as String ='...' # non-nilable string with or without (0 length) value 51 if s.length 52 print 's not empty' 53 else 54 print 's is length 0' 55 assert s1 # always succeeds - non nilable (warning) 56 assert s1.length # succeeds if s1 is not empty ( > length 0) 57 45 58 46 59 l = [] # empty list … … 57 70 nb = nil 58 71 assert nb # also fails variable is nil 59 72 73 #nilable Object 74 shouldBeFalse as Object? = false # bool value typed as nilable Anything 75 assert shouldBeFalse == false # ok 76 shouldBeTrue0 = not shouldBeFalse # tests against nil only 77 assert shouldBeTrue0 == true # fails assertion 78 shouldBeTrue = not (shouldBeFalse to bool) 79 assert shouldBeTrue == true # ok 60 80 }}} 61 81