|
As far as I can tell, throw expressions only exist to make expression-bodied members work. Without them, you'd have to check for null and throw an ArgumentNullException , which would mean multiple lines, and therefore prevent you from using an expression body.
I'm sure some people will find a use for them. But I still much prefer using multi-statement bodies when there are multiple statements to execute.
And I'm not really a fan of using expression-bodied methods for properties with more than one accessor either.
public string Name
{
get => name;
set => name = value ?? throw new ArgumentNullException(nameof(value));
}
public string Name
{
get => name;
set
{
if (value == null) throw new ArgumentNullException(nameof(value));
name = value;
}
}
public string Name
{
get
{
return name;
}
set
{
if (value == null) throw new ArgumentNullException(nameof(value));
name = value;
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Lambdas have become so important for the language that I don't see the issue with expression-bodied members. It's pretty easy to figure out what they mean even if you've never seen them before. But I can see the argument for "it wasn't needed so why add it?"
The throw expressions with a null-coalescing operator, however, is a very logical addition in my opinion. It just makes sense. That operator is great for two things: defaults on null and errors on null. Until now you couldn't do the second instead having to fall back on if(X == null) throw /*error*/ . Granted that isn't much boilerplate compared to the handler code that was simplified with ?. , but it just makes sense that ?? should make it unnecessary.
|
|
|
|
|
Oh, I can see the value in it, but like I said, someone new to this looks at that and goes "what the is THAT?!". I know this because I had three people who have some curly language experience come up, see this, and said that very thing.
|
|
|
|
|
I use what I need to get the job done - if it is that syntax and is readable and easy to maintain...
|
|
|
|
|
It's becoming like every other ms product: 90% of the features must be [at best] barely useful.
(feeling kind today - avoiding negatives.)
Signature not found error error: Unable to throw signature not found error.
|
|
|
|
|
Never used it exactly like this, no. But I've used it when using a lambda to satisfy a delegate/action/func parameter with at least one parameter of its own where I literally do not care about the lambda parameter. Ex. _ => { /*....*/ }
|
|
|
|
|
Dont know, pretty sure there is a C# forum for this question though.
|
|
|
|
|
If you refuse to pay your tv licence you get sent to prison where you can watch tv all day without needing one
|
|
|
|
|
And you get free food, medical care, and...
|
|
|
|
|
And....... have to fight over the remote?
|
|
|
|
|
..and free soap on the shower floor. I'd still prefer a decent hotel, can't see why people think it is a nice place to stay
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Soapbox!
... such stuff as dreams are made on
|
|
|
|
|
That's where this should have been in the first place.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Doesn't hurt as much if you do
|
|
|
|
|
But some bad mates. I like more to work with gentle and intelligent mates
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
and the opportunity to live in a gated community.
|
|
|
|
|
Pom Pey wrote: you can watch tv all day without needing one
Someone else is paying for the license, but I do understand the point you are making.
|
|
|
|
|
Yeah the government paying the government
|
|
|
|
|
So, remembering that this is soapbox material, what do you propose?
Ending the government?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: Ending the government? Belgium tried that and it seemed to work quite well. Is the country any better since you got one back again (or two if you count EU)?
|
|
|
|
|
They didn't. Belgium did not turn to anarchy, rule of law was still in place, as was the government. Yes, the people that were chosen to represent them were having trouble with forming a cohesive group, but that does not mean that government was abandoned.
There are enough places where anarchy is still the norm. I'd like to challenge anyone who thinks that "no government" magically solves anyything to explain it to me there. It will be a very short discussion.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
It would be cheaper to pay crims £40,000 a year than to lock them up.
There is logic for you.
|
|
|
|
|
Too expensive. You need to practice moar[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
We need an island somewhere we can dump them. And leave them to it. They can farm, make their own society, whatever they like. Just as long as they f*** off and leave decent people alone.
|
|
|
|
|
We tried that already, several times.
Since we all know black holes are actually portals, we should send the B-ark to Sagittarius.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|