5 ms·
I don't think it's that they've run out of ideas, it's that they're being picky with what they implement as C# is fairly modern but also fairly mature. This isn
by Moto7451 11y ago
I don't think it's that they've run out of ideas, it's that they're being picky with what they implement as C# is fairly modern but also fairly mature. This isn't like the C++ revolution of the past few years where they've been adding new, interesting, (and sometimes dramatically different) features to a decades old language.
Regardless, this change is very handy. Even if "everything must go in a class" is a bad idea (I think it's fine), the end result of this change, from the library consumer's standpoint, is the same as having functions defined outside a class but within a namespace. It's a great pragmatic change that doesn't rock the boat much.
In line with that are the other mostly minor but time saving changes like simplified null coalescing.
public static string Truncate(string value, int length)
{
return value?.Substring(0, Math.Min(value.Length, length));
}
In previous versions this looks like:
public static string Truncate(string value, int length)
{
return value != null ? value.Substring(0, Math.Min(value.Length, length)) : null;
}
Not a huge change, but a very handy one to have.
- maxlybbert 11y agoI recognize that this particular change is meant as a convenience. But I'm not the person who put the exclamation mark in the part that I quoted from the article. And it makes me laugh that one feature they specifically call out is the ability to do what programming languages could do in, say, 1958 ( https://en.wikipedia.org/wiki/ALGOL_58 https://en.wikipedia.org/wiki/ALGOL_58 ).