Are we able to do this in gambas
if we have a class called Vector with a function "subtract" can we then do
Vector mouse = new Vector(mouseX,mouseY);
Vector dir = Vector.subtract(mouse,location);
Static Functions
- cogier
- Site Admin
- Posts: 1128
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Static Functions
Hi ShaneP and welcome to the forum.
Can you explain exactly what you want to achive. I'm not sure I understand the question that well.
Can you explain exactly what you want to achive. I'm not sure I understand the question that well.
Re: Static Functions
Your example is chock full of reserved (or previously used) words, so I'm not going to manipulate it into proper syntax.
The answer is "Yes, you can"
Static subs can only reference static variables. Static variables are shared across all instances. A static sub can create an instance of the class and return it. A static sub can also take an instance as an argument. Of course, the same is true for non-static (instance methods) too.
It shouldn't be too difficult for you to whip up an example project to demonstrate this. If you encounter any trouble, just ask for help.
Ced
The answer is "Yes, you can"
Static subs can only reference static variables. Static variables are shared across all instances. A static sub can create an instance of the class and return it. A static sub can also take an instance as an argument. Of course, the same is true for non-static (instance methods) too.
It shouldn't be too difficult for you to whip up an example project to demonstrate this. If you encounter any trouble, just ask for help.
Ced
.... and carry a big stick!