My heading above – Value vs. Reference Variables – I got from ChatGPT since I don’t know what I’m talking about. At any rate, here’s my question: I create a variable (QstDft) from a class I made (QAClass) in a method, set the new variable (QstDft) to some new property values and … the original class variable – in this case QstClass(0) – resets to the new properties. It then is exactly the same as my method variable, QstDft.
dim QstDft as new QAclass ’ Sets QstDft to default values
QstDft = QstClass(0)
QstDft.Question = QstClass(Item).Question
QstDft.Answer = QstClass(Item).AnswerQstClass(Item) = QstDft ’ Sets to default values
I’ve had this come up before with simpler variables. ChatGPT tells me “In Xojo, when you assign one variable to another, the behavior depends on whether the variables are value types or reference types. It sounds like you’re working with a reference type, where both variables point to the same underlying object in memory.”
Any help would be appreciated.
22 posts - 9 participants