Declaring variables with and without type inference

The complete source of structure_declarations.ek9, compiled by the EK9 compiler. Shown on structure.html.

#!ek9
defines module site.structure.declarations

  defines program

    Declarations()
      stdout <- Stdout()

      name1 as String?
      name2 as String := String()
      name3 as String := "Some Value"
      name4 as String := String("Some Value")

      //Inferred type declaration
      name5 <- "Another Value"
      name6 <- String()

      name1: "Assigned later"
      stdout.println(`${name1} ${name2?} ${name3} ${name4} ${name5} ${name6?}`)

Download structure_declarations.ek9

Output

Assigned later false Some Value Some Value Another Value false