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

Re: [sc-dev] String:escapeSpaces



Scott Wilson wrote:
 Any reason not to add this:

 + String {
 escapeSpaces {
 var result;
 this.do({ arg char;
 if(char.isSpace,{result = result ++ $\\ ++ " "},{result = result ++ char})
 });
 ^result
 }
 }

 and then stick it in in the various String methods which deal with paths?

why not factor isSpace into a predicate that is passed to the method
along with the escape character? would make it more useful in other
contexts, and escapeSpaces could just be ^this.escapeChars(_.isSpace, $\\);

<sk>


there is already an efficient way to replace parts of strings:

"my/ path".replace(" ", "")
--





.