How To Make A Branch Statement
Print Hello World
Write Basic Syntax
Use Properties
Make An If Else Ladder
Make A Branch Statement
Declare Inits
Use Lists
Use Arrays
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
Customize Object Equality
Pass References To Methods
Translate Pseudo Code To Cobra 1
Translate Pseudo Code To Cobra 2
Implement IEnumerable 1
Implement IEnumerable 2
Iterate Through Recursive Data With Yield
Make A Collection Class
Declare Contracts
Threads
Win Forms
WPF
GTK
Qyoto
Access MySQL
XNA
Open TK
 
"""
MakeABranchStatement.cobra

General syntax:

    branch WHAT
        on VALUE1
            STATEMENTS1
        on VALUE2
            STATEMENTS2
        [else
            STATEMENTS]

    branch WHAT
        on VALUE1, STATEMENT1
        on VALUE2, STATEMENT2
        [else, STATEMENT]

Key rules of the branch statement:

    * What's being branched on must be an integer, character, enumeration or string.

    * The expressions being matched must be constants (ex: 0, 1, 'x', State.Off, "foo").

When a branch statement isn't feasible, you can possibly:

    * Make a class hierarchy and send a message to the object.

    * Use an `if-else` ladder (see MakeAnIfElseLadder.cobra)


See also: MakeAnIfElseLadder.cobra, CheckInheritanceAndImplementation.cobra.
"""


class Program

    def main

        word = ''

        # This is the general syntax, below. Notice the keywords `branch` and
        # `on` as well as the indentation under each `on` part:
        x = 2
        branch x
            on 1
                isEven = false
                word = 'one'
            on 2
                isEven = true
                word = 'two'
            on 3
                isEven = false
                word = 'three'
        assert isEven
        assert word == 'two'

        # In addition to `on`, you can put an `else` at the end:
        x = 2
        branch x
            on 1
                word = 'one'
            on 3
                word = 'three'
            else
                word = 'else'
        assert word == 'else'

        # If there is only one statement for the `on` or `else` and you want to
        # tighten up your code, you can do so by using a colon (,) and putting the
        # statement on the same line, like so:
        x = 2
        branch x
            on 1, word = 'one'
            on 3, word = 'three'
            else, word = 'else'
        assert word == 'else'

        # You can have more than one value for `on`:
        x = 2
        branch x
            on 1 or 2 or 3, word = 'number'
            else, word = 'else'
        assert word == 'number'

        # You can also branch on enumerations, strings and characters.