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
""" MakeAnIfElseLadder.cobra Consider possible alternatives to an if-else ladder: * Make a class hierarchy and send a message to the object. * Use the `branch` statement (see MakeABranchStatement.cobra) When using an if-else ladder, consider raising a FallThroughException() at the bottom if you expect that it should never happen. See also: MakeABranchStatement.cobra, CheckInheritanceAndImplementation.cobra. """ class Program def main is shared t = Thing() if t.isSmall print 'small' else if t.isMedium print 'medium' else if t.isLarge print 'large' else throw FallThroughException(t) # ^ As seen here, you can (optionally) include a value with the # fall-through exception which is the value that was being examined. class Thing """ A thing is always small, medium or large, and never more than one. """ get isSmall as bool return false get isMedium as bool return true get isLarge as bool return false