Help understanding compiler errors, where is String coming from?


Can someone help me understand why the compiler thinks I need a String at error(88,73)?

Here are the errors I get from the compiler.


This great tail of woe will soon be history.

The cause is any2stringadd, an implicit conversion from Any, that gives you a + method to concatenate strings.

I tried to copy your code to give some more details, but I’m on my phone, which doesnt have good OCR facilities.


Opps, I found my own error. The problem was I had forgotten the call to “match”, within the slice function.


Hi Marti, thanks for the information. Yes, it is not clear whether to me it is more helpful to copy-paste text into a discussion in this forum, and hence lose the highlighting and red squiggly error indications. Or whether to upload an image, and lose the copy-paste text ability for the readers. sigh.


Always text and compiler output. If possible self contained so that the issue can be reproduced by pasting into the repl.


Just to underscore Martijn’s point: any2stringadd was one of those things that seemed like a good idea at the time (a long, long time ago), but which has turned out to be an ongoing nightmare.

Broadly speaking, any time you get an error from the compiler where it seems to want a String for no apparent reason, look for a +. Odds are that it’s trying to interpret the right-hand side of that as String because you don’t have any other legal interpretation of +. This is a common error when working with the standard collections…