Wiki

Changes between Version 3 and Version 4 of NilableTypes

Show
Ignore:
Timestamp:
11/22/10 20:05:33 (7 years ago)
Author:
todd.a
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NilableTypes

    v3 v4  
    1111e.g. 
    1212{{{ 
     13#!cobra 
    1314    str as String = "Mystring"    # str can only have a String value 
    1415    strN as String?               # strN may have a String value OR nil 
     
    2021 
    2122{{{ 
     23#!cobra 
    2224    def sendWelcome(cust as Customer, referral as Customer?)  
    2325        # will not accept nil for `cust` 
     
    3941e.g. 
    4042{{{ 
     43#!cobra 
    4144    s as String = 'a string' 
    4245    sn = s to ?    # sn is String? 
     
    4952You can explicitly test for nil or not nil values using normal conditionals (true is non-nil) 
    5053{{{ 
     54#!cobra 
    5155    s as String = 'sss' 
    5256    assert s 
     
    6973'''a !  b ''' evaluate b if a not nil.   
    7074{{{ 
     75#!cobra 
    7176    stuff as String? = nil 
    7277    defaultStuff='DEFAULT'