Hi,

Personally, I would write your code [as 
follows](https://glot.io/snippets/ekzfjeht1v):
    
    
    type
      Keypad = ref object
        position: range[1..9]
    
    proc newKeypad(): Keypad =
      result = Keypad(position: 5)
    
    let keypad = newKeypad()
    

Note that method isdynamically dispatched, whilst proc isstatically dispatched. 
Methods can't be removed with dead code elimination, so proc is usually 
preferred. The convention newX is also used throughout the standard library.

Also note that object initialization uses the colon (:) to specify the value of 
a field.

Reply via email to