I'm hobby programmer and just started playing around with Nim and so far I'm
very happy with it. Unfortunately I got stuck on a problem and can't seem to
solve it. I want to add a subrange field to an object with the following code:
type
Keypad = ref object
position: range[1..9]
method new(this: type Keypad):Keypad =
result = Keypad()
result.position = 5
var keypad = Keypad.new()
When I run it the compiler complains about "_Error: field not initialized:
position_". I tried changing to **position: range[1..9]=5** but then I got
"_Error: initialization not allowed here_" instead.
What is the recommended way to solve this?
(also, is this way of faking a constructor a good solution?)