[Ethereum] Solidity return array from struct

solidity

I use solidity with web3.js and know that we actually cannot return the whole struct array, but I would like to know if it is possible to return only a type in the struct as an array.

Lets say i have the following struct:

struct aStruct {
    bytes8 a; 
    bytes8 b;
}

aStruct[10000] aStr;

Can I now make a function, where I return aStr.a, the whole "a" as an array?

Best Answer

I'm going to go out on a limb here and say you probably don't want to do that, even if you could, which you can't, at least for now.

The blockchain is not like other platforms. Some of the changes are hard to accept because they're opposite of what experience teaches.

Iteration over a set is almost always a client-side concern. It's easy to see how a client with the whole data set can figure that out on its own. You shouldn't burden the contract with a concern the clients can address without assistance.

This might help explain where I'm coming from. https://medium.com/p/2303010c8b09/