Let's say I have a string and want to make it uppercase.
I would do:
str = str.toUpperAscii()
Is there any in-place way to do the same? (like Ruby's str.upcase!)
I'm not particularly interested in the uppercase function. I'm looking for some more... universal approach.
Unfortunately there are many functions like this in the standard library which only return copies.
The introduction of dup in Nim 1.2.0 is helping to fix all this, but it appears to be a long-term plan where (perhaps in Nim 2.0) the standard library will only offer in-place versions of most functions, and you can use dup when you really want a copy.
For the time being, I'd recommend to just roll your own solution (make a utils file in your project or something) :)
proc upcase(s: var string) =
for c in mitems(s):
c = c.toUpperAscii()