Static Functions

Post

Posted
Rating:
#1 (In Topic #293)
Trainee
 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);
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
Cedron is in the usergroup ‘Regular’
 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

.... and carry a big stick!
Online now: No Back to the top
1 guest and 0 members have just viewed this.