HadesLang Doc
  • Overview
  • Getting Started
    • Installing Hades
    • Basic Syntax
    • Coding Conventions
  • Language Spec
    • Foundation
      • Types
      • Built-in functions
    • Operators
      • Comparison and equality
      • Logical operators
      • Bitwise operators
      • Compound Assignment Operators
      • Operator overloading
    • Control flow
      • Conditions
      • Loops
      • Exception handling
      • Ternary and nullcheck operators
      • Pipelines
    • Classes and variables
      • Declaring variables
      • Declaring classes
      • Declaring structs
      • Declaring protos
      • Declaring arrays
      • Type conversions in simple variable types
    • Actors
      • Message passing
      • GenServer
      • Channels
    • Functions and lambdas
      • Declaring functions
      • Declaring lambdas
    • Functions of simple types
      • int
      • string
      • float
      • bool
      • atom
      • pid
    • Other
      • Annotations
      • Comments
      • Preprocessor statements
      • Reflection
      • Script file arguments
      • this keyword
  • Core Libraries
    • Standard library
      • std:io
        • console
        • file
        • directory
      • std:exceptions
      • std:int
      • std:internals
        • annotations
          • findMethod
          • findMethodInProto
          • findMethods
          • findMethodsInProto
        • function
      • std:collections
        • map
        • list
      • std:math
        • math
        • constants
        • matrix
      • std:networking
      • std:os
      • std:params
      • std:string
      • std:sql
    • Extra libraries
      • mssql:client
  • Other
    • Tools
    • Examples
    • Todos
Powered by GitBook
On this page
  • Comparison
  • Equality
  • Of same types
  • Of different types
  • Checking type
  1. Language Spec
  2. Operators

Comparison and equality

Comparison

We can compare values using C style comparison operators:

less < than
lessThan <= orEqual
greater > than
greaterThan >= orEqual

Equality

Of same types

We can test two values for equality:

Example

1 == 2 //false
"2" is "2" //true

And for inequality:

Example

1 not 2 //true
"2" != "2" //false

Of different types

We can test different types for equality (which will, by default, always evaluate to false).

Example

314 == "pi" // false
123 is "123" // false

And for inequality (which will, by default, always evaluate to true).

Example

314 not "pi" // true
123 != "123" // true

Checking type

In Hades, the equality operator also works as a typecheck. You can check any value against a proto or type. The operation will return true if the value is an instance of said proto.

Example

123 == int // true

var v = VideoStream("bigbuckbunny.mp4")
v is Vector // false
PreviousOperatorsNextLogical operators

Last updated 5 years ago