Is there a way in Nim to define constructors for an object? For example I have
type Deck* = ref object
cards* : array[52, Card]
can I create an empty constructor that creates automatically all the cards?
Is there a way in Nim to define constructors for an object? For example I have
type Deck* = ref object
cards* : array[52, Card]
can I create an empty constructor that creates automatically all the cards?
type
Card = int
Deck* = ref object
cards* : array[52, Card]
proc newDeck: Deck =
new result
for i, c in result.cards.mpairs:
c = i
© 2022 - 2024 — McMap. All rights reserved.
new
operator should now be avoided. – Mina