nim-lang / RFCs

A repository for your Nim proposals.
136 stars 26 forks source link

Object Default Values #253

Closed al6x closed 3 years ago

al6x commented 3 years ago

Provide a way to define default values for object fields, read rendered markdown

Example

type
  Protoss = object
    race: string = "Protoss"
    name: string

echo Protoss(name: "Zeratul")
echo Protoss(name: "Artanis")

CC @dom96

al6x commented 3 years ago

@dom96 I was going to write PR for object initialization shortcuts separately, here it is

timotheecour commented 3 years ago

closing as duplicate of https://github.com/nim-lang/RFCs/issues/252 which was already accepted. All we need is a PR to implement it.

more details here: https://github.com/nim-lang/RFCs/issues/252#issuecomment-705113779

feel free to re-open if you disagree it's a duplicate