Skip to content

Instantly share code, notes, and snippets.

@yakkomajuri
Created July 14, 2020 17:22
Show Gist options
  • Save yakkomajuri/7b911e65cf1fcd1d103665e805dd0866 to your computer and use it in GitHub Desktop.
Save yakkomajuri/7b911e65cf1fcd1d103665e805dd0866 to your computer and use it in GitHub Desktop.
import strformat
# Example taken from the Nim Website: https://nim-lang.org/
type
Person = object
name: string
age: Natural # Ensures the age is positive
let people = [
Person(name: "John", age: 45),
Person(name: "Kate", age: 30)
]
for person in people:
# Type-safe string interpolation,
# evaluated at compile time.
echo(fmt"{person.name} is {person.age} years old")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment