We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I was surprised to find that while
enum Schedule { Hourly(?minute:Int); // ... }
is possible, this is not:
enum Schedule { Hourly(minute:Int=1); // characters 18-19 : Unexpected = // ... }
Right now I have to do additional null-checks on enums with optional parameters like so
var instance = new MyClass(Schedule.Hourly()); function MyClass { var schedule:Schedule; public function new(var schedule:Schedule){ // validate schedule switch (schedule) { case Hourly(minute): // check for null and apply a default value if found if(minute == null) { minute = 1; schedule = Schedule.Hourly(minute); } else if (minute < 0 || minute > 59) throw "Hourly.Minute must be >= 0 and < 60"; } // ... } this.schedule = schedule; } }
instead of simply:
var instance = new MyClass(Schedule.Hourly()); function MyClass { var schedule:Schedule; public function new(var schedule:Schedule) { // validate schedule switch (schedule) { case Hourly(minute): if (minute < 0 || minute > 59) throw "Hourly.Minute must be >= 0 and < 60"; // ... } this.schedule = schedule; } }
Therefore I would request adding default value behaviour for enums as specified here https://haxe.org/manual/types-function-default-values.html
The text was updated successfully, but these errors were encountered:
This would have to go through https://github.com/HaxeFoundation/haxe-evolution.
Sorry, something went wrong.
HaxeFoundation/haxe-evolution#27
No branches or pull requests
I was surprised to find that while
is possible, this is not:
Right now I have to do additional null-checks on enums with optional parameters like so
instead of simply:
Therefore I would request adding default value behaviour for enums as specified here https://haxe.org/manual/types-function-default-values.html
The text was updated successfully, but these errors were encountered: