Solidity Strange Skills (1)

Punkcan
·
·
IPFS
·

Today I will talk about how Array can not specify the length.

Anyone who has written it knows that in Solidity, if you want to define a variable as Array, you need to specify whether it is memory or storage.

If it is memory, the length must be specified when the variable is first created.

For example, if your Array is directly created by inserting a certain value, the Array cannot be increased in length, that is, it cannot be pushed.

It's really troublesome

But I found that the Array in the mapping does not need to define the length

mapping(uint256=>address[]) _need;

In this way, you can have an Array of free length.

CC BY-NC-ND 2.0

Like my work? Don't forget to support and clap, let me know that you are with me on the road of creation. Keep this enthusiasm together!

Punkcan加密宇宙裡的擺渡人 聲音及電腦視覺藝術創作 數據控,喜歡音樂美食書寫思考 人在江蘇,只有Wechat比較好使 Wechat ID:stormychaos https://punkcan.art/
  • Author
  • More

Web3 小白书:去中心化是什么?

Glassnode 2022 年 10 月 31 日 周报小结

Aptos 优势分析及后续市场评估