The Cobra Programming Language
How To
Print Hello World
Write Basic Syntax
Use Properties
Make An If Else Ladder
Make A Branch Statement
Declare Inits
Make A Class Hierarchy
Use Nil And Nilable Types
Use Dynamic Typing
Declare Variable Number Of Args
Read And Write Files
Check Inheritance And Implementation
Pass References To Methods
Translate Pseudo Code To Cobra1
Translate Pseudo Code To Cobra2
Implement IEnumerable1
Implement IEnumerable2
Iterate Through Recursive Data With Yield
Make A Collection Class
Declare Contracts
Threads
Win Forms
GTK
Access MySQL
""" 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