String:collect


part of wslib


change of behaviour for String:collect.


String:collect ( function )

instead of only accepting Chars as output of the function, String:collect now accepts anything as output, and adds it to the output string. This might change behaviour of other methods such as tr


"teststring".collect({ |char| " " ++ char }); // inserts spaces before every char


"teststring".collect({ |char|if( char == $s ) { "" } { char } }); // removes "s"


"teststring".collect({ |char| char.ascii });


"teststring".tr( $s, "zzzz" );  // previously the to argument could only be a Char