RosettaCodeData/Task/Enforced-immutability/Nim/enforced-immutability.nim
2023-07-01 13:44:08 -04:00

7 lines
284 B
Nim

var x = "mutablefoo" # Mutable variable
let y = "immutablefoo" # Immutable variable, at runtime
const z = "constantfoo" # Immutable constant, at compile time
x[0] = 'M'
y[0] = 'I' # Compile error: 'y[0]' cannot be assigned to
z[0] = 'C' # Compile error: 'z[0]' cannot be assigned to