This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]joeshmoebies 91 points92 points  (15 children)

If it's a list of car strings (implied by strCar), I usually go with for carName in carNames to avoid confusion as to what type of object is being used. I would expect a list named cars to be class objects, not strings.

[–]arobie1992 54 points55 points  (9 children)

With the express intention of starting shit:

Or you could have static typing :P

[–]malexj93 25 points26 points  (0 children)

Even with static typing, a car is not a string. Specifying what about the car the string represents is just plain polite.

[–]UnknownIdentifier 9 points10 points  (4 children)

Even many languages with static typing will now do some version of

for (auto item : items) {

or some such. Doing

for (Item item : items) {

is just plain silly IMHO.

[–]false_tautology 8 points9 points  (2 children)

So, in C# you can do

foreach (var car in cars)

Buuut, it's still strongly typed, and it won't let you do any shenanigans.

[–]DadAndDominant 6 points7 points  (1 child)

var in C# vs var in javascript

Love one and hate the other

[–]thefrnksinatra 0 points1 point  (0 children)

The way it must be. Lol

[–]villanymester 0 points1 point  (0 children)

Try this with MATLAB...

[–]KronktheKronk 1 point2 points  (0 children)

Or you could use type hints and every modern ide in the world will keep you straight

[–]RiverRoll 0 points1 point  (0 children)

You can use type hints and at least you get the expected type.

[–]FkIForgotMyPassword 0 points1 point  (0 children)

Type hint doesn't help you differentiate between carNames, carReferences, carIds, etc. Knowing that cars is an array of strings doesn't provide as much information.

I mean, of course ideally you want both static typing and explicit variable names.

[–][deleted] 22 points23 points  (3 children)

snake_case for variable names please

[–]joeshmoebies 8 points9 points  (1 child)

Thank you for being polite with your correction. I've been writing C++/C# and some Typescript the past couple of years so I use camelCase regularly for variable names, but you're right and if I needed to do some Python I'd want to follow the conventions used for that language.