[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] string.replace




So we could just add this:

replace { arg find, replace;
        find = find.asString;
        ^super.replace(find, replace).join
}


that would be messy:

n = nil;
"blarg".replace("la", n);

"bnilrg"



On Wed, Dec 2, 2015 at 6:53 PM Scott Wilson <i@xxxxxxxxxxxxxx> wrote:
Context:

This happened as I found some silent failures, which led to a review of all primitives to identify ones which did not check for bad types and swallowed errors. There were a number where this was incorrectly done and stuff would just quietly not work.

The String ones perhaps need more nuanced handling, although FWIW I did check with the original author of the relevant code to see if the previous implementation of those was intentional or just an oversight. It wasn’t intentional.


Yes, this is a consequence of that change. We should keep considering the way it behaves, however.

I can adjust these to accept other types. What would be helpful would be if we could first come up with a specification for what such methods should accept. Certainly Chars seem reasonable in this case.

S.