-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple assignments on a single line. #65
Comments
👎 |
1 similar comment
👎 |
👍 |
downvote. On Tue, Jun 18, 2013 at 3:04 PM, Jonathan Gaillard <[email protected]
|
👍 |
I can go either way on that sort of multiple assignment. I can see how it can impact readability but sometimes it makes more sense and is far more compact than writing things out the other way, like judicious use of the ternary operator. What I've seen elsewhere is code like $foo = something; $bar = somethingElse; and all on one line. 🎱 |
👍 |
Don't care one way or the other. Does anybody want to make a case for one On Wed, Jun 19, 2013 at 9:16 AM, Katherine Kenyon
|
as evident with great languages like golang, putting a standard in that at least has some majority favor and is enforced (by the sniff) leads to much faster readability, less squabble, better search opportunities etc etc. in the long run. really people can get used to whatever given a little time.. but its more important some standard goes in |
of course I will post fix in saying this or course isn't priority over business logic |
The main reason for doing multiple assignments at once is conciseness as it allows you to initialize a bunch of variables to the same value all at once. The main reason against it is that it makes it harder to find the variable initialization by scanning the code because some of the variables aren't being assigned at the beginning of their line. |
My response follows on Jonathan's : I'm pretty sure 99% of programmers are most used to multiple line variable Therefore I lean towards what is easiest to read/maintain & for new hires On Wed, Jun 19, 2013 at 9:49 AM, Jonathan Gaillard <[email protected]
|
Ok, I'm on board with that line of thinking. On Wed, Jun 19, 2013 at 10:11 AM, RAGoody [email protected] wrote:
|
@RAGoody, it depends. In languages where you have to declare your variables (especially when doing so at the top of functions), you very often see multiple initializations at once to different values. The multiple assignments in a line has come from that: // C/C++
void main()
{
int x=5, y=10;
//...
} // Javascript
function foo() {
var x=5, y=10;
// ...
} That being said, I don't know that I agree with that standard even in those languages. |
Our standard currently allows code like this:
Do we want to continue allowing that?
👍 if you like multiple assignments in one statement
👎 if you don't
@dominionenterprises/dws-arch, @dominionenterprises/tol-rec-dev, @dominionenterprises/tol-industrial-dev feel free to leave your preference.
👍 : 3
👎 : 3
The text was updated successfully, but these errors were encountered: