Open utterances-bot opened 2 years ago
Hello, I'm not sure if I'm simply misreading the documentation, but if I were to copy paste this exactly into the https://try.haxe.org/#7cb8d815, it would not show me the commented output.
Rather, it displays [Object object]
. Do I need to implement/override any toString
function?
@Mariosyian That's an annoying "hello-world-optimization" on the JS target, where Haxe doesn't include its own trace implementation to reduce the output size (and instead uses the standard console.log()
). A simple way to force Haxe to include its own trace is to trace something with multiple arguments at least once:
trace(myList, "");
@Gama11 Thank you for the swift response, yes that works perfectly. Any chance the documentation could be updated to reflect this? It's extremely confusing to someone like me, who has just started learning Haxe.
Is there a way to initialize a list with elements? I'm making a state machine for my app and I want to add the default state (from an enum) directly. The state variable is public static
so I can't use the constructor.
enum State {
NORMAL;
ERROR;
}
class AppState {
public static var stateType: List<State> = new List(); // Initialize a list with objects here
public static var stateInfo: String = "";
public static function trigger() {
// TODO
}
}
List - Haxe - The Cross-platform Toolkit
Haxe is an open source toolkit based on a modern, high level, strictly typed programming language.
https://haxe.org/manual/std-List.html