Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6338387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:26:05+00:00 2026-05-24T19:26:05+00:00

I’m in charge of creating coding standards and doing code reviews within my organization.

  • 0

I’m in charge of creating coding standards and doing code reviews within my organization.

I came cross something within our source code like this:

object.Property = myVar1 = myVar2;

I don’t personally do this because I find it confusing. I see this and I want to read it like this:

object.Property = myVar1 == myVar2;

Now I know what it’s doing: It assigns myVar to myVar2 and then object.Property to myVar2. The coding standards document doesn’t explicitly state whether or not you can do this. It does state however to not assign variables within an if statement.

I guess my question is, is it bad enough style to draw out as a coding practice to not do it? I don’t like making code standard policies “just because I said so”

Edited to better explain my understanding

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:26:06+00:00Added an answer on May 24, 2026 at 7:26 pm

    This so-called “chained assignment” is indeed controversial and there are quite a few questions on SO that address it.

    It is a byproduct of assignment being an expression and not a statement, as you know, and to many people it can be confusing.

    It many languages it is somewhat dangerous to novices. In languages where [] is a constructor for empty array objects, writing

    a = b = []
    

    makes a and b reference the same object. Novices tend to think it makes two separate empty arrays which can be filled independently. Not so! The C# equivalent,

    a = b = new SomethingOrOther();
    

    is arguably far less likely to occur, since a and b would be more likely to be initialized at the point of declaration, and such double assignments would be rarer, and furthermore C# programmers are more likely to see the obvious sharing in this case.

    A good rationale for instituting a prohibition against this is three-fold:

    1. It is completely unnecessary.
    2. It is error-prone (as in the array example above).

    When you encounter error-prone constructs, you should avoid them because in avoiding them, you will never make that particular error. Granted, in C#, it may be far less error prone than in other languages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I want to count how many characters a certain string has in PHP, but
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.