4 ms·
Sure, I would have preferred a non-branching: std::string pad = descriptive_name_here(path); with the added bonus of being able to add "const" to that, for th
by knorker 10y ago
Sure, I would have preferred a non-branching:
std::string pad = descriptive_name_here(path);
with the added bonus of being able to add "const" to that, for the benefit of the reader.
This is not relying on compiler implementation! Can you name one language that has strings that initialise to anything but a valid object containing an empty string?
This is not an obscure side-effect. This is like assuming "std::vector<int> v;" creates an empty vector, not a undefined-state vector container.
(I don't want someone coding C++ as if all objects are references. Coding in one language as if it were another is a well-known antipattern)
- rbadaro 10y agoIn Java the default value for a String (or any object) is null, not an empty string.
- knorker 10y agoDid you not read my whole comment? Please read the whole thing before replying.
- rbadaro 10y agoRead the whole comment. Still don't see nothing that invalidates my answer to "Can you name one language that has strings that initialise to anything but a valid object containing an empty string?".
- knorker 10y agoYou specifically mentioned Java, and I specifically mentioned reference-based languages, with Java being the most obvious example.