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
  1. Language Spec
  2. Operators

Compound Assignment Operators

A compound assignment operator executes an operation (with the variable on the left being the left operand) and then assigns the result to the variable on the left. There are no compound assignment operators for logical operations.

  • Multiply and assign (*=)

  • Divide and assign (/=)

  • Modulo and assign (%=)

  • Add and assign (+=)

  • Subtract and assign (-=)

  • Left bit shift and assign (<<=)

  • Right bit shift and assign (>>=)

  • Bitwise and and assign (&=)

  • Bitwise xor and assign (^=)

  • Bitwise or and assign (|=)

Example

var a = 12

a += 3 //a is 15
a %= 4 //a is 3
a <<= 8 //a is 768
a &= 524 //a is 512
a >>= 2 //a is 128

PreviousBitwise operatorsNextOperator overloading

Last updated 6 years ago