0

I am using a string utility library for Solidity with the aim of splitting a string on a specific delimiter. I followed the instructions from the library:

var s = someString.toSlice();
var foo = s.split("-".toSlice());

logString(foo);

However, I'm getting an error with the logString(). The online Solidity IDE says

TypeError: Invalid type for argument in function call. Invalid implicit converstion from struct strings.slice memeory to string memory requested. 
    logString(foo);
              ^-^

How can I properly print out the sliced portion of the string?

1

I don't know how logString() is defined, but I imagine it takes a string argument. split() returns a slice, so you need to convert it to a string:

logString(foo.toString());

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.