|
I saw this in a code sample on a JetBrains web page. Can you spot the problem(s)?
using System;
public class Class1 {
private Action _someAction;
public void Method() {
var obj1 = new object();
var obj2 = new object();
_someAction += () => {
Console.WriteLine(obj1);
Console.WriteLine(obj2);
};
_someAction += () => {
Console.WriteLine(obj1);
};
}
}
This should be easy to figure out.
|
|
|
|
|
Am I missing something? Besides the erroneous comment (obj1 is captured, not obj2) I see no issues
|
|
|
|
|
Not sure what that code's trying to do, but the delegate gets both functions added to its invocation list, and this is repeated each time the containing method is called.
|
|
|
|
|
Yea. I guess I was assuming there was another error - not just pointless code. With the naming, I can't even be absolutely sure that isn't intended behavior
|
|
|
|
|
This is why you don't give matches or scissors to unsupervised children under 10 years old.
If only software devs would consider similar wisdom for programmers with under 10 years experience.
Signature ready for installation. Please Reboot now.
modified 14-Apr-18 0:56am.
|
|
|
|
|
James Lonero wrote: Can you spot the problem(s)? Yes.
1) Somebody actually wrote it.
2) See (1).
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
And what invokes the action?
This space for rent
|
|
|
|
|
I know politics are not allowed but I can't help myself, have to post.
>“I don’t know Mr Libby,” Mr Trump said in a quote provided alongside a statement announcing
>the pardon, “but for years I have heard that he has been treated unfairly. Hopefully this full
>pardon will help rectify a very sad portion of his life.”
BTW first post in the lounge.
0200 A9 23
0202 8D 01 80
0205 00
|
|
|
|
|
GrooverFromHolland wrote: I know politics are not allowed but I can't help myself, have to post.
That's what the soapbox is for -- when you can't help yourself.
|
|
|
|
|
Didn't know who "Mr Libby" was, or what he did, what his relationship to Trump is, or why Trump might want to "pardon" him for whatever he did, until I looked it up just now.
And now that I know, I still don't understand exactly why you "had to post" as it pretty much sounds like a non-event.
|
|
|
|
|
someone had to, so it might as well be me.
0200 A9 23
0202 8D 01 80
0205 00
|
|
|
|
|
|
GrooverFromHolland wrote: someone had to
I'm not convinced of that.
So far, others seem to agree.
|
|
|
|
|
"Trump"? Trump who? Pardoning whom for what?
I don't watch the news very much - it's very comforting.
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
And I don't know this Mr Trump, but he sure made America a great source of entertaining news (again?)!
Mission accomplished!
|
|
|
|
|
Super Lloyd wrote: but he sure made America a great source of entertaining news
Very true. Every day. It is like when he isn't saying something stupid it almost makes one wonder if he seriously ill.
|
|
|
|
|
Super Lloyd wrote: but he sure made America a great source of entertaining news
That was the goal of the "Make America Great Again" slogan.
|
|
|
|
|
He did basically come directly from a reality show, so maybe that was his real plan.
|
|
|
|
|
No, you did not have to sh*t post in the Lounge. Looks like you have 4 votes for an inappropriate post.
|
|
|
|
|
|
That kind of behavior will backfire as soon as a even bigger dick comes around the corner.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Note that the article was written by a comedian
|
|
|
|
|
Good that you told me. I was about to become a commedian myself and try them out. All at once.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Got it now I need a trick to remember them.
Everyone has a photographic memory; some just don't have film. Steven Wright
|
|
|
|
|