Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Root797677yYou can have "duck typing" without auto typecasting.
In this case it's allowing different methods to operate on the data, such as looping, slicing, indexing, counting, injecting, etc. on iterables. This isn't changing the data's type, but adding a wrapper to standard methods. -
@Zezura auto can be pretty damn useful, especially when you're writing generic code
-
@Zezura and how is being lazy bad? And could you provide some examples as to why to bugs? Never had any that were caused by using auto (and I'm using it extensively)
-
@Zezura if I ever ended up in that situation, I'd consider redesigning my code
Even if that's not possible, 'auto' doesn't make it any worse. You already know the type, so does the compiler. Even if you forget it: every decent IDE displays it when you hover over the variable -
@Zezura yes, of course, but let's be honest: how often are you using that kind of variable?
That being said, I only use it where I can save the effort of writing a type twice
(For example:
auto some_ptr = std::make_unique(new int[30]);
Over
std::unique_ptr<int[]> some_ptr = std::make_unique(new int[30]);
) or when iterating over a vector(or similar)
As useful as it can be, I despise auto-typecasting.
That is all.
undefined
1+1=11
typecasting