官术网_书友最值得收藏!

Mappings

Mappings are a special type of variable in the sense that they can hold an endless amount of data. It's like a combination of an array and a struct. You can add elements to it for a set of types:

mapping(string => bool) public validStrings;

Mappings store information as an unlimited array. They work similar to objects in JavaScript, where each key has a value associated and they can be accessed randomly. They don't have a fixed length, nor can you get the length of them, as with arrays, for looping their values. What you must do instead is save the latest updated key of your mapping and go from there.

You can set values for mappings as follows:

validStrings['example'] = true;

In our example, all values of validStrings will be false until you set them to true.

主站蜘蛛池模板: 新晃| 从化市| 邵阳县| 德庆县| 翁牛特旗| 郑州市| 榕江县| 黑山县| 梁平县| 广安市| 凤台县| 德安县| 驻马店市| 山阳县| 五华县| 庆安县| 黔东| 保亭| 宜宾县| 汨罗市| 井冈山市| 卢湾区| 潞城市| 锦州市| 竹北市| 郴州市| 鄱阳县| 隆化县| 工布江达县| 乌鲁木齐市| 淮安市| 陆良县| 工布江达县| 鹤山市| 兴国县| 北票市| 青浦区| 镇原县| 庆安县| 嘉定区| 乌拉特前旗|