Chapter 2: changing a value, typed
Chapter 2's smallest program declares a value, changes it, and changes it again from its own old value. Nothing here is structure a tool could write for you, so the IDE writes the program's shell and you type the three lines and their comments. To play it in the IDE: Help > Lessons > Getting Started with EK9…, or ek9 -ide -lesson book-mutation.
What you'll build
The lesson builds this program from a file holding only its module line - the finished file, as the book prints it.
#!ek9 defines module values.mutation defines program Mutation() stdout <- Stdout() score <- 0 //declare 'score', starting at 0 score := 10 //change it to 10 score := score + 5 //change it to 15 stdout.println(`Final score is ${score}`) //EOF
Step 1: The program's shell
Choose Code > New Construct > Program…
Mutation is the program's name. Type it and choose Preview.
The preview shows Mutation about to be written. Choose Apply.
The tool leaves no blank line before the program: select the Mutation() line and, above it, type the one the book opens with. Saves when typed.
Step 2: The body, typed
Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it. Saves when typed.
Step 3: Run it
Choose Run > Run Program…
The project's only program is already chosen. Choose Run.
Final score is 15 - declared at 0, then 10, then 10 + 5. Choose Close.
The result
Mutation.ek9 now reads exactly as chapter 2 of Getting Started with EK9 shows it: declared with <-, changed with :=, and changed once more using its own current value.
Where this lesson comes from
- For AI assistants - the MCP tool
ek9_add_program.
In the EK9 reference: EK9 Basics








