C# I hate you for that!

  • 13
    What if you wanted to use the outer comment variable in the lambda? I think the language is okay.
  • 0
    Js ftw lol
  • 7
    Language is fine. The fuck are you complaining about?
  • 1
    @Lensflare I hate you for that!
  • 7
    White theme is not C#'s fault but your own
  • 4
    Everyone knows the proper lambda param is x.
  • 1
    looks very ok to me
  • 0
    You cannot use the outer comment variable in the labda because it is not even assigned a value before the lambda executes.
    It makes no sense for the compiler to demand a different variable name.
    It only encourages the use of inproper lambda param names like x.
  • 0
    @flake Know the language. I know it more than most of the morons not able to comprehend what i am complaining about. And I know other languages that behave differently in this case. Just because you think it is normal and expected because you learned that it is how it is, doesn't mean I can't hate it.
  • 1
    @Lensflare Namecalling others with a rant like this is a stellar display of irony my man. I’m amused.
  • 1
    @grumpyoldaf I'm sorry. It makes me angry when people don't even try to listen and think that I just don't know the language. It even isn't the point. Like @flake who suggested I should learn the language and then appearently removed his comment.
    To make it clear: My rant is not about why c# does that. It is about that it is shit to do that.
    That is my rant. No need to make it look like I don't know what I am talking about like many did.
  • 1
    @Lensflare he removed his account (one of his many)
  • 0
    @Lensflare I understand what you mean. Is it a hassle to have to use different names? Yes. Would it be worse to be given the ability to unknowingly hide a variable you had maybe 4 scopes before? I personally think they made the right choice not letting us use the same name.
    I often prefer when they try to protect me from my own forgetfulness :)
  • 0
    @dozingncoding I would agree if the declaration of the outer variable would be one line earlier. But in my example, the inner and the outer variables should not have access to each other. So it should be ok. C# obviously does something special in this case which forbids this code to compile. But I am pretty sure it is some technical reason.

    I love it when the compiler is protecting me from making subtile errors but this one is the compiler being annoying for some subtile technical c# implementation reasons. 😌
  • 1
    @Lensflare but lines make no difference in c#

    //this line
    var comment = aggregate.Comments.Single(comment => comment.Key.Id == commentId);
    //is exactly the same as
    var comment = aggregate.Comments
    .Single(comment=>comment.Key.Id == commentId);
  • 1
  • 0
    @dozingncoding I know. I meant of course one statement earlier.
    Comment comment;
    comment = aggregate.(...);
  • 2
    Oh this highlight bot looks useful 😄
  • 1
    @Lensflare You know that these two are equivalent to the compiler, right?
  • 0
    @Krokoklemme are you sure? That would explain some things. I know for a fact that it is not the same for the Swift compiler, for example. Just in case you are assuming it to be a normal or obvious thing.
  • 0
    @Lensflare yeah, pretty sure. The resulting parse tree should be the same in either case

    idk about Swift though, maybe it does some extra stuff to distinguish them?
Your Job Suck?
Get a Better Job
Add Comment