How To Use Dynamic Typing
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
 
"""
Cobra supports both static and dynamic typing.

See also: http://cobra-language.com/docs/release-notes/Cobra-0.5.0.html
"""

class Person

    get name as String
        return 'Blaise'


class Car

    get name as String
        return 'Saleen S7'


class Program

    shared

        def main
            assert .add(2, 3) == 5
            assert .add('Hi ', 'there.') == 'Hi there.'
            .printName(Person())
            .printName(Car())

        def add(a, b) as dynamic
            return a + b

        def printName(x)
            print x.name  # dynamic binding


class Notes

    def add(a, b) as dynamic
        return a + b
        # + flexible (any type with "+" operator works)
        #   + fast prototyping
        #   + less brittle wrt other software components that change unpredictably
        # + more reusable
        # - errors detected late (run-time)
        # - one error reported at a time (the first one that throws an exception)
        # - slow at run-time
        # - fat at run-time (values must carry type information; boxing)
        # - difficult IDE support
        #   (Intellisense/autosuggestion requires complex analysis and/or execution of code)

    def add(a as decimal, b as decimal) as decimal
        return a + b
        # - inflexible
        #   - slower coding / more typing
        #   - more brittle (to change program to `float` you must find and replace everywhere)
        # - less reusable (cannot use with int and float)
        # + errors detected early (compile-time)
        # + multiple errors reported (every one that the compiler can find)
        # + fast at run-time
        # + slim at run-time (values need only carry data)
        # + easy IDE support (Intellisense/autosuggestion)