Chuyển đến nội dung chính

Bài đăng

Hiển thị các bài đăng có nhãn Storage solidity

Tự học Solidity bài 19: Storage & Memory trong ngôn ngữ lập trình Solidity

Storage & Memory Ngôn ngữ lập trình Solidity. Tài liệu tự học Solidity.  Trong khoá học online miễn phí Tự học lập trình web3 - Tự học ngôn ngữ lập trình Solidity Summary for English Visiter Sandwich[] sandwiches; function eatSandwich(uint _index) public { // So instead, you should declare with the ` storage ` keyword Sandwich storage mySandwich = sandwiches[_index]; mySandwich.status = "Eaten!"; // If you just want a copy, you can use ` memory `: Sandwich memory anotherSandwich = sandwiches[_index + 1]; anotherSandwich.status = "Eaten!"; sandwiches[_index + 1] = anotherSandwich; } Thank you! Vị trí dữ liệu Trong Solidity, có hai vị trí bạn có thể lưu trữ các biến - trong bộ lưu trữ Storage và trong bộ nhớ Memory . Storage  trỏ đến các biến được lưu trữ vĩnh viễn trên blockchain .  Memory là các biến là tạm thời và bị xóa giữa các lệnh gọi hàm. Có thể hình dung nó giống như lưu trữ dư liệu trong ổ đĩa cứng và  RAM .