Skip to content

Block Structure

Harneet uses curly braces {} to define blocks of code. These blocks group statements together.

Blocks

  • Purpose: Blocks are used to group statements, typically associated with control flow statements (like if, for, switch) or function definitions.
  • Syntax: Statements within a block are enclosed in curly braces {}.
Block Structure
1
2
3
4
5
6
package main
import fmt
if condition {
    // statements inside the block
    fmt.Println("Condition is true")
}

Statement Terminators

Harneet supports both newlines and semicolons as statement terminators. You can use either, or mix them.

  • Newline: A new line implicitly terminates a statement.
  • Semicolon: A semicolon ; explicitly terminates a statement.
Statement Termination
1
2
3
4
5
6
7
// Using newlines
package main
var x = 10
var y = 20

// Using semicolons
var a = 1; var b = 2;

Indentation

Indentation is not syntactically significant in Harneet (unlike Python), but it is highly recommended for readability and maintaining consistent code style.