Re: Subrange field not initialized

2016-12-07 Thread filip
Thank you, your code and comments taught me alot!


Re: Subrange field not initialized

2016-12-06 Thread euant
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.