|
There is no warning, which surprised me - and I have "treat warnings as errors" set by default ...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
There (sort of) is a warning for self-assignment. If you assign
value3 = value3 you do get a warning. If you assign
Value3 = Value3 you do not get a warning.
Strange, the warning must only be for self-assignment of variables, but not properties?
|
|
|
|
|
Not that strange: properties are syntactic sugar for getter and setter methods, so what you are actually doing is:
Value3 = Value3;
==
Value3_setter(Value3_getter()); But the compiler should have spotted it:: lazy programmers strike again ...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Yeah, in their defense, I guess there are cases where that "self-assignment" might actually have "desired" side effects (such as modifying some other local variable). Though, I'd still like it if the compiler kicked out a low level warning...mostly, because I'm bound to make that mistake myself sometime
|
|
|
|
|
It often issues warnings when there is also an error. Otherwise you're on your own...
We're philosophical about power outages here. A.C. come, A.C. go.
|
|
|
|
|
I have had a number of cases where Visual Studio suggests that I should make a variable readonly, for reasons somewhat similar to this one (and I have had similar problems spotting it).
That is when there is only a single assignment to the one variant of the name - it is not smart enough to detect that I have declared two differently named variables for the same "real world" value, using one name in half of the statements, the ohter one in the other half. I wish it was that smart (I can think of only one time this happened, though.)
|
|
|
|
|
Ugh. Uppercase vs Lowercase errors always drive me crazy!!!
|
|
|
|
|
That's why I only write programs in BASIC and Pascal.
Well, sometimes I get modren and use FORTRAN.
|
|
|
|
|
you misspelled value3 .
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
You forgot to capitalize the first letter of your sentence.
|
|
|
|
|
that's okay, because my sentence is not part of any widely recognized API...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
You under-estimate your importance, IJSOP.
Software Zen: delete this;
|
|
|
|
|
My vote is NOT ENOUGH coffee.
|
|
|
|
|
In c++ you will get at least a warning "Parameter value3" not used
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Chris Maunder wrote: Why is MyObject.Value3 always equal to 0?
Because your code is doing what you told it to do - not what you want it to do?
(That is usually my problem with my code!)
Socialism is the Axe Body Spray of political ideologies: It never does what it claims to do, but people too young to know better keep buying it anyway. (Glenn Reynolds)
|
|
|
|
|
The programmer's lament:
I really hate this damn machine -
I wish that they would sell it.
It doesnt't do the thing I want,
but only what I tell it!
(source unknown)
|
|
|
|
|
|
All languages have their stupid parts, this is in my opinion one of the major ones of the languages deriving from C.
|
|
|
|
|
Unfortunately that happens, and aging doesn't help.
Interestingly enough, in spite of 0x01AA remark, g++ doesn't complain about
class Foo
{
int F;
public:
Foo(int f){F = F;}
But it does complain about (which is, by the way, the construct every sensible C++ developer would have chosen)
class Foo
{
int F;
public:
Foo(int f):F(F){}
spitting out a sane
warning: ‘Foo::F’ is initialized with itself
|
|
|
|
|
|
I don't even know what language this is, but I will presume Java.
You have Value3 being assigned to the value of ... Value3, so nothing happens there. Evidently, it is initialized to the value of 0. Is it a default int when there is no declaration type?
|
|
|
|
|
C#, and exactly.
Stared and stared and stared and debugged and stared and had another coffee then...
C# will warn you if you do "=" instead of "==" but I was surprised it didn't warn about X = X.
cheers
Chris Maunder
|
|
|
|
|
you forgot to put _ in front of your parameter names.
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
Looks like you've committed a capital offence!
|
|
|
|
|
I looked at it and looked at it and didn't see it either.
|
|
|
|