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

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.

主站蜘蛛池模板: 司法| 临泽县| 西盟| 本溪市| 祁阳县| 抚松县| 宣化县| 庆阳市| 铁岭县| 辰溪县| 靖江市| 福泉市| 侯马市| 文登市| 奇台县| 彩票| 蓬莱市| 澄城县| 乡城县| 册亨县| 浮山县| 清新县| 遂宁市| 江达县| 博湖县| 金秀| 大丰市| 寿宁县| 桐庐县| 河西区| 庆阳市| 伽师县| 将乐县| 沂源县| 盘锦市| 岚皋县| 辽源市| 新丰县| 资源县| 锦屏县| 永清县|