So you have both a getter method and a public variable. In that case, you cannot refer to both of them. It appears that the current engine will bind to a variable with a getter before a getter method is found, but this isn't guaranteed in the future. Instead, you should use distinct names so as to avoid confusion. This would be a poor practice anyways, as it would cause confusion to anyone reading the source code.
Could you please define "ghost variable"? If you mean, something like this: http://www-sop.inria.fr/everest/personnel/Mariela.Pavlova/ghost.pdf, then, no, there's no such support (nor is it necessary). You can use assert functions to verify your logic programmatically, though. If I'm completely up the wrong tree, please let me know so I can help you further.
You can declare a variable only once in each scope. It is possible, therefore, to define a variable x in at most three places simultaneously within a class:
A static variable named x, accessed by "classname.x".
A class variable named x, accessed by "this.x".
A function variable named x, accessed by "x".
You can not "shadow" a variable within the same function or same class.
So you have both a getter method and a public variable. In that case, you cannot refer to both of them. It appears that the current engine will bind to a variable with a getter before a getter method is found, but this isn't guaranteed in the future. Instead, you should use distinct names so as to avoid confusion. This would be a poor practice anyways, as it would cause confusion to anyone reading the source code.
So you have both a getter method and a public variable. In that case, you cannot refer to both of them. It appears that the current engine will bind to a variable with a getter before a getter method is found, but this isn't guaranteed in the future. Instead, you should use distinct names so as to avoid confusion. This would be a poor practice anyways, as it would cause confusion to anyone reading the source code.
All Answers
Could you please define "ghost variable"? If you mean, something like this: http://www-sop.inria.fr/everest/personnel/Mariela.Pavlova/ghost.pdf, then, no, there's no such support (nor is it necessary). You can use assert functions to verify your logic programmatically, though. If I'm completely up the wrong tree, please let me know so I can help you further.
Yes friend. i want to know in Salesforce can i use same variable name to decalre two different data types declarations in apex?
Thanks for reply.
Reds,
Buss
You can declare a variable only once in each scope. It is possible, therefore, to define a variable x in at most three places simultaneously within a class:
A static variable named x, accessed by "classname.x".
A class variable named x, accessed by "this.x".
A function variable named x, accessed by "x".
You can not "shadow" a variable within the same function or same class.
Hi,
i declared two variables as below
public Integer pagBlk{set;}
public Boolean getpagBlk(){
return oppty!=null;
}
here two variables as instance varaibles.
then, how would i refer both variable in VF page, becuase if i refer first variable where for second variable also same variable it refering.
Reds,
Buss
So you have both a getter method and a public variable. In that case, you cannot refer to both of them. It appears that the current engine will bind to a variable with a getter before a getter method is found, but this isn't guaranteed in the future. Instead, you should use distinct names so as to avoid confusion. This would be a poor practice anyways, as it would cause confusion to anyone reading the source code.