What does mean ampersands and dots before variable name?
E.g.
PHP Code:
PHP Code:
|
Re: What does mean ampersands and dots before variable name?
. allows you to specify which values are used for which parameters.
For example, set_task header looks like this: PHP Code:
PHP Code:
But, maybe you want to fill them in a different order or explicitly state which value is for which parameter(useful in natives with a lot of parameters to make it clear what parameter is being set to what value). Then you can do: PHP Code:
PHP Code:
But, this alone is not terribly useful. The "true" usage of this is so you can skip some parameters you do not need while specifying a later parameter. In your example you had: PHP Code:
If you wanted to write this without the "."(dot notation) you would have to give all the intermediate parameters a value: PHP Code:
When you pass by reference, informally, you pass the actual variable so if you change it inside the function, the change will be visible to the caller function. PHP Code:
PHP Code:
In your example, with cs_get_user_team, the model parameter can store/"return" the model id. It has to be a reference(&) in order to implement this functionality. |
Re: What does mean ampersands and dots before variable name?
Not sure that i understood about ampersands but thank you so much
PHP Code:
|
Re: What does mean ampersands and dots before variable name?
Yes. When using &, x is passed by reference so the modification is visible in plugin_init(x is now 3).
y is passed by value(no &) and will still be 2 in init. Also, just to be clear, instead of plugin_init you can have any function. The general rule is that whem using & the modifications are visible to the caller function. You could easily test this out by printing x and y to the console using server_print. Or make a command and print to chat. |
Re: What does mean ampersands and dots before variable name?
Nice @HamletEagle. I still see and learn new things here. That function .parameters
|
Re: What does mean ampersands and dots before variable name?
Quote:
|
| All times are GMT -4. The time now is 02:32. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.