Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pass param by reference or private variable?
Message
De
02/10/2019 08:21:06
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01671293
Message ID:
01671323
Vues:
48
>Hi,
>
>I need a method of a object to return some strings (actually two). I can declare the variables as Private before calling the method and set the values of the variables inside the method.
>Or I can declare the variables Local and pass them by reference (with @). Therefore, when passing by reference the variable value can be set within the method and afterward get the value.
>What is better practice?

I know you found a good solution and it's likely what I would do, as well. But I wanted to answer the original question. It's bad practice in general for a routine to assume that certain variables exist. While passing parameters to a function by reference isn't great (such a function is said to have "side effects"), it's a better choice.

Tamar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform