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

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.

主站蜘蛛池模板: 财经| 延长县| 兴文县| 寿阳县| 宕昌县| 依安县| 金秀| 郸城县| 泗洪县| 武威市| 汕头市| 同仁县| 东阳市| 武功县| 繁昌县| 仪陇县| 馆陶县| 汨罗市| 永寿县| 固原市| 沙坪坝区| 泰顺县| 澄迈县| 西宁市| 张家港市| 肥东县| 明星| 洛南县| 延川县| 岳阳县| 开化县| 抚宁县| 城口县| 蒙阴县| 法库县| 珲春市| 海城市| 巴塘县| 营口市| 汶川县| 天镇县|