Skip to content

Instantly share code, notes, and snippets.

Created September 4, 2021 16:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A gist displaying how to use the static vs instance properties.
//A class; a template for creating objects with the properties listed in the class
class Duck {
static public var CAN_FLY:Bool = true;
public var age:Int;
public function new(age:Int) {
this.age = age;
class Test {
static function main() {
var ducky = new Duck(3);
// A static property uses the class name in order to access the element
// ducky.CAN_FLY = false; //Try uncommenting this line and see what happens
// Using the instance variable to change the age
ducky.age = 4;
Copy link

KinoAR commented Sep 4, 2021 You can try the example here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment