would like to float the idea of
@:optional var space = 0.;
is replaced with
var space ?= 0.;
My contexct is I am slightly confused on @:initStruct can I still have a constructor afterwards? For example I was wanting to use initStruct to clarify construction with:
class Label extends Actor {
public var content: String;
public var font: Font;
public var color: Color;
public var size: Int;
public var spacing: Float;
public var image: Image;
public var useImage: Bool;
public function new( content_: String
, font_: Font
, color_: Color
, size_: Int
, ?spacing_: Float = -1.
, ?x_: Float = 0., ?y_: Float = 0.
, ?useImage_: Bool = true ){
content = content_;
font = font_;
color = color_;
size = size_;
spacing = spacing_;
useImage = useImage_;
var width_: Float;
if( spacing == null ){
width_ = font.width( size, content );
} else {
var dW = 0.;
for( i in 0...content.length ) {
dW += font.width( size, content.substr( i, 1 ) );
dW += spacing;
}
width_ = dW - spacing;
}
var height_ = font.height( size );
super( width_, height_, x_, y_ );
if( useImage ) generateImage();
}
//... more methods
But I am unsure, is there an example use case of also calling new? Also I am unsure if I can indicate some how that some private parameters in this class or the super should be set later not at construction the current situation is that you could set any private property at construction which could be very problematic, how can the user know what they are allowed/suggested to setable?
would like to float the idea of @:optional var space = 0.; is replaced with var space ?= 0.;
My contexct is I am slightly confused on @:initStruct can I still have a constructor afterwards? For example I was wanting to use initStruct to clarify construction with:
But I am unsure, is there an example use case of also calling new? Also I am unsure if I can indicate some how that some private parameters in this class or the super should be set later not at construction the current situation is that you could set any private property at construction which could be very problematic, how can the user know what they are allowed/suggested to setable?