website
website copied to clipboard
Nim homepage -- example is identical as in features
And one more, sorry
import strformat
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")
That example is fine, but identical to first example on Features page. That is a bit boring and not very good advertising.
Ok, can you think of a better example that would go either on the homepage or in the features page?
For features page maybe a sort algo, insertionSort() or recursive quickSort() (We all know the problems of recursive quicksort, but should be ok for example.)
https://rosettacode.org/wiki/Sorting_algorithms/Insertion_sort#Nim
https://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Nim
Well the example on features page is not fully identical, it has an additional bug: name is marked with an export marker, but object Person is not exported. That makes no sense.
Thinking more about it, a small async, threading or GUI example would be nice for features page too.