Hey all!
I've been using Nim for a week now and starting to be able whatever I need. I used to do PHP for 10y, then moved to Python and JavaScript for 10y also and now discovering Nim.
Reasons I left these languages is for getting one that is strong typing, and also to get more logic into functions.
Nim seemed to be a good choice, though I find some WTF in the language; therefore I must probably miss some light, hence this question :)
strutils.strip and strutils.stripLineEnd seem quite close with each their specific action. However one is immutable, and the other mutes the string.
let readFile("content.txt").strip
-> ok
let readFile("content.txt").stripLineEnd
-> error
We should change the writing to
var content = readFile("content.txt")
content.stripLineEnd
I find it quite incoherent as I did in previous languages. What is the logic behind this? Do you agree with this behavior?
Currently, strutils is quite inconsistent with its usage of var vs non-var strings, mostly due to its age. You can always use dup to make stripLineEnd outplace:
import std/sugar # for dup
let content = readFile("content.txt").dup(stripLineEnd)