actor {
type Post = {
id : Int;
creater : String;
};
stable var Posts : [Post] = [];
func addPost(id : Int, creater : String) : () {
Posts.push(id, creater);
};
};
How can I push an object in that mutable array that is defined as Posts
?
It seems that you are looking for
Array.append
, however as it is deprecated, you should useBuffer
s withpreupgrade
andpostupgrade
instead of the following: