Cobra/Keywords/pass

Материал из Викиучебника — открытых книг для открытого мира

Pass[править]

pass — оператор-заглушка, ничего не делающий.

Используется в качестве заполнителя или пустого оператора, где ничего не нужно делать.

Синтаксис[править]

pass

Пример[править]

def methodNeededForInterface # but not used
    pass

# simplify complicated code flow.
if .complicatedExpression0
    if .expression1 and .expression2 and not .expression3 or expression4 
        pass # all is well
    else if expression1 and not expression2
        .expressFailure
    else if .expression3
        .expressFailure2
    # ...


# property with both getter and setter, setter must be available but does nothing
pro isUsed as bool
    get
    return false
    set
    pass

try
   .doOperation
catch FormatException
   pass    # trap and discard the exception