The Cobra Programming Language
How To
PrintHelloWorld
WriteBasicSyntax
UseProperties
MakeAnIfElseLadder
MakeABranchStatement
DeclareInits
MakeAClassHierarchy
UseNilAndNilableTypes
UseDynamicTyping
DeclareVariableNumberOfArgs
ReadAndWriteFiles
CheckInheritanceAndImplementation
ImplementIEnumerable1
ImplementIEnumerable2
IterateThroughRecursiveDataWithYield
MakeACollectionClass
AccessMySQL
"""
How to declare and use variable number of arguments:

    * Put the `vari` keyword before the type of the argument.
    * Use a `for` loop to enumerate through them.

You don't need to specify the type of the variable in the `for` loop. Cobra
infers that from what is being enumerated.

Also the var args are compatible with IEnumerable<of T> and IEnumerable.
So you can pass the argument wherever those types are expected.
"""


class Test

    def allTrue(stuff as vari dynamic?) as bool
        """
        Returns true only if all the stuff passed in is true.
        """
        for x in stuff
            if not x
                return false
        return true

    def sumInts(stuff as vari int) as int
        """
        Return the sum of all the ints.
        """
        sum = 0
        for x in stuff
            sum += x
        return sum

    def main is shared
        t = Test()
        assert t.allTrue(1, 3.0, true)
        assert not t.allTrue(1, 0, true)
        assert t.sumInts(1, 2, 3)==6