Just wondering …the obvious way to use the value/key pairs of a map to do multiple substitutions in a string is to use strings.replace() however it would be nice to do this with a function that does this in a single call rather than looping for each key/value pair. Does anyone know of a better way?
Such a function should be trivial to write.
However the order of the keys in a map isn’t predictable so if you have a map with substitutions like “aa”: “x” and " an": “y” anf then given the string “aab” could you not be sure if it would be transformed into “xb” or “ay”.
Yeah, it was trivial and I probably shouldn’t have even asked. I’m just spoiled when it comes to maps because I came from PHP which has boat load of array (go map) functions making it unnecessary to use loops for array/map operations an impressive amount of the time… of course PHP is looping internally anyway but that’s a different matter.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.