Skip to content

Returning Array instead of an Object when calling automatic getter for a mapping to struct? #1789

Answered by ricmoo
LuisHPorras asked this question in Q&A
Discussion options

You must be logged in to vote

This is the perfect channel to discuss this. :)

This way the method returns the same type of object whether you use function bar() returns (uint256, bool) and function bar() returns (uint256 a, bool b). The same goes for nesting structures, arrays and anything else.

Otherwise code which accepts a contract as a parameter would have to inspect what type of ABI was used for a given method to determine how to decouple it (since it could be an object in some case, and Array.isArray and typeof Would be of little use, since the result could legitimately be an array).

So it makes code that programmatically extends a Contract and Result much easier, since it can always just use positional argument…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@LuisHPorras
Comment options

Answer selected by LuisHPorras
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants