aboutsummaryrefslogtreecommitdiffstats
path: root/docs/frequently-asked-questions.rst
diff options
context:
space:
mode:
authorRJ <catalanor0220@gmail.com>2016-03-30 02:05:42 +0800
committerRJ <catalanor0220@gmail.com>2016-03-30 02:05:42 +0800
commit0c5156ca50f23b4fe8efb08fc8993e65a3126ae4 (patch)
treef433e7c1f7bf626da5b2800cce882e11c7f620d8 /docs/frequently-asked-questions.rst
parent5dd81360a9a53652f4f57677d76419f92a3ff856 (diff)
downloaddexon-solidity-0c5156ca50f23b4fe8efb08fc8993e65a3126ae4.tar
dexon-solidity-0c5156ca50f23b4fe8efb08fc8993e65a3126ae4.tar.gz
dexon-solidity-0c5156ca50f23b4fe8efb08fc8993e65a3126ae4.tar.bz2
dexon-solidity-0c5156ca50f23b4fe8efb08fc8993e65a3126ae4.tar.lz
dexon-solidity-0c5156ca50f23b4fe8efb08fc8993e65a3126ae4.tar.xz
dexon-solidity-0c5156ca50f23b4fe8efb08fc8993e65a3126ae4.tar.zst
dexon-solidity-0c5156ca50f23b4fe8efb08fc8993e65a3126ae4.zip
Update frequently-asked-questions.rst
Diffstat (limited to 'docs/frequently-asked-questions.rst')
-rw-r--r--docs/frequently-asked-questions.rst17
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst
index f960a0d6..9e59e010 100644
--- a/docs/frequently-asked-questions.rst
+++ b/docs/frequently-asked-questions.rst
@@ -172,6 +172,23 @@ Are mappings iterable?
Mappings themselves are not iterable, but you can use a higher-level
datastructure on top of it, for example the `iterable mapping <https://github.com/ethereum/dapp-bin/blob/master/library/iterable_mapping.sol>`_.
+Can I put arrays inside of a mapping? How do I make a mapping of a mapping?
+===========================================================================
+
+Mappings are already syntactically similar to arrays as they are, therefore it doesn't make much sense to store an array in them. Rather what you should do is create a mapping of a mapping.
+
+An example of this would be::
+ contract c {
+ struct myStruct {
+ uint someNumber;
+ string someString;
+ }
+ mapping(uint => mapping(string => myStruct)) myDynamicMapping;
+ function storeInMapping() {
+ myDynamicMapping[1]["Foo"] = myStruct(2, "Bar");
+ }
+ }
+
Can you return an array or a string from a solidity function call?
==================================================================