Hello,
I see there are various implementations of Seq interface, but at runtime I get class class exception when retrieving the values in such a structure.
It seems like type inference cannot tell what is inside that structure?
Sometimes it is an ArrayList<List<Array<...
I cannot use the Iterator to traverse it, as there is no awareness of the elements inside it at runtime.
E.g:
I have written some validators which all return Seq<String> for the errors data structure, and I expected it to be independent of the runtime implementation when calling methods on the interface: like iterator method: reduceLeft.
Seq<String> errorsIterator = exception.getValidationResult().getError();
String errors = errorsIterator.iterator().reduceLeft((s, s2) -> s +" " + s2);
java.lang.ClassCastException: io.vavr.collection.Array cannot be cast to java.lang.String
Why isn't this error shown at compile time? It forces the client to call instanceOf on elements and take decisions from there.
Thank you,
Livia
I don't meet the ClassCastException before.
Can you show reproducible code example with ClassCastException?
@liviamoroianu could you please provide us with a minimal working example? E.g. by hard coding/substituting a minimal version of exception.getValidationResult().getError() that leads to the error you described.
@liviamoroianu I hope you don't mind if I close this issue because of house-keeping. I think the issue is located on the call-site, not within Vavr.
Nevertheless, if you could give us a MWE (see above) I will re-open the issue and fix it.
Most helpful comment
@liviamoroianu I hope you don't mind if I close this issue because of house-keeping. I think the issue is located on the call-site, not within Vavr.
Nevertheless, if you could give us a MWE (see above) I will re-open the issue and fix it.