Skip to content
Discussion options

You must be logged in to vote

Yes it's intentional,, because reference.variable will always be not a reference by default, and instead a move.

This is the recommended approach.

// Retrieve an &mut reference of MessageBoard
let message_board = borrow_global_mut<MessageBoard>(address);

// Retrieve the reference to the messages, if it's not a reference, the compiler will complain, as it is moving it out of a mutable reference.
let messages = &mut message_board.messages;

// Using the mutable reference, push an object onto the vector
vector::push_back(messages, object);

Replies: 1 comment

Comment options

0x-j
Aug 13, 2024
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by 0x-j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
move Questions related to the Move Language
1 participant