0
pragma solidity ^0.4.0;

// delete an array of names
contract ArrayDelete {
string[] names;

function main() returns (string[]) {
   names.push("Jones");
   names.push("Ama");
   names.push("Emeka");
   names.push("Owo");
   names.push("Lulu");

   delete names[0];
   return names;
 }
}

Any ideas why this error occurs? None of the answers on similar questions was helpful in fixing this.

3

You can't return a dynamic array of dynamic arrays from a Solidity function. From the Solidity docs:

Is it possible to return an array of strings (string[]) from a Solidity function?

Not yet, as this requires two levels of dynamic arrays (string is a dynamic array itself).

  • 2
    "You can't return a dynamic array from a Solidity function." This is inaccurate. You can return a dynamic array, but you can't return a dynamic array of dynamic arrays. (string is a dynamic array.) So a return type of uint256[] is fine but not string[]. – user19510 Jan 26 '18 at 21:51
  • 1
    So anything method that has to deal with something similar will have make use of numbers? What's the work around for doing this with strings ? – Bernard 'Beta Berlin' Parah Jan 26 '18 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.