How To Customize Object Equality
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
Win Forms
Access MySQL
Open TK
class Foo

    cue init(i as int, s as String)
        _i, _s = i, s
    pro i from var as int

    pro s from var as String

    # Cobra will invoke a strongly typed .equals method
    # for == and <> between two statically typed objects:
    def equals(other as Foo) as bool
        return other.i == .i and other.s == .s

    # Override Object.equals
    # Cobra will use this in dynamic situations
    # and the .NET libs may use this in others,
    # such as using Foo as a key in a dictionary:
    def equals(obj as Object?) as bool is override
        if obj inherits Foo, return .equals(obj)
        return false

    # When you override Object.equals, you should override .getHashCode:
    def getHashCode as int is override
        return HashCodeUtils.combine(.i.getHashCode, .s.getHashCode)

class Program

    def main
        assert Foo(5, 'foo') == Foo(5, 'foo')
        assert Foo(5, 'foo') <> Foo(2, 'foo')