I populate a list from an array
type Card = {
getName: () -> Text;
getValue: () -> Nat;
};
private let cards:[var Card] = Array.init(numberOfCards, Cards.Card("","",0));
private var cardsToDeal: List.List<Card> = List.fromVarArray<Card>(cards);
public func deal(): Card {
let (card, list) = List.pop<Card>(cardsToDeal);
Debug.print(debug_show(cards[0].getName()));
Debug.print(debug_show(card.getName()));
}
This works:
Debug.print(debug_show(cards[0].getName()));
This doesn’t:
Debug.print(debug_show(card.getName()));
and errors with:
type error [M0070], expected object type, but expression produces type ?Card/1
What does the List.pop() return?