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
""" MakeACollectionClass.cobra This HowTo shows the syntax and techniques for declaring an IList. """ class MyList<of T> implements IList<of T> var _items as List<of T> def init _items = List<of T>() ## IEnumerable ## def getEnumerator as IEnumerator<of T> return _items.getEnumerator def getEnumerator as System.Collections.IEnumerator implements System.Collections.IEnumerable return .getEnumerator ## ICollection ## get count as int return _items.count get isReadOnly as bool return false def add(item as T) _items.add(item) def clear _items.clear def contains(item as T) as bool return _items.contains(item) def remove(item as T) as bool return _items.remove(item) def copyTo(array as T[], index as int) _items.copyTo(array, index) ## IList ## pro [index as int] as T get return _items[index] set _items[index] = value def indexOf(x as T) as int return _items.indexOf(x) def insert(index as int, x as T) _items.insert(index, x) def removeAt(index as int) _items.removeAt(index) class Program def main is shared t = MyList<of int>() t.add(5) assert t.count==1