Skip to content

Operators and Expressions

Harneet supports a variety of operators for performing arithmetic, comparison, and logical operations.

Arithmetic Operators

  • +: Addition
  • -: Subtraction
  • *: Multiplication
  • /: Division
  • </: Floor division (rounds toward negative infinity)
  • %: Modulo (remainder)

Comparison Operators

  • ==: Equal to
  • !=: Not equal to
  • <: Less than
  • >: Greater than
  • <=: Less than or equal to
  • >=: Greater than or equal to

Logical Operators

  • and: Logical AND (short-circuiting)
  • or: Logical OR (short-circuiting)
  • not: Logical NOT

Assignment Operators

  • =: Assignment
  • :=: Short declaration and assignment

String Concatenation

The + operator can be used to concatenate strings.

String Concatenation
package main
var greeting = "Hello, " + "World!"

Precedence

Harneet follows standard mathematical operator precedence. You can use parentheses () to group expressions and control the order of evaluation.