HaxeFoundation / haxe.org-comments

Repository to collect comments of our haxe.org websites
2 stars 2 forks source link

[code.haxe.org] Beginner - Declare classes #63

Open utterances-bot opened 4 years ago

utterances-bot commented 4 years ago

Declare classes - Beginner - Haxe programming language cookbook

Create a new class with two functions and create a new instance of it.

https://code.haxe.org/category/beginner/declare-classes.html

cambiata commented 4 years ago

Hm, should @:structInit be mentioned here? It's very convenient and a bit underused, I think.

markknol commented 4 years ago

@cambiata Good idea, feel free to add it!

cambiata commented 4 years ago

Cool, I will, asap.

ccpplinux commented 1 year ago

When I am running the Calculator class then I am getting following error message: Calculator.hx:21: characters 1-6 : Unexpected trace

When I am commenting out the last two trace then the program is running. But as soon as I am uncommenting trace then it is giving error message.

Can you tell me reason for this error message?

Aurel300 commented 1 year ago

@ccpplinux The last part of the snippet (after "// Create a new instance of the Calculator") is meant to represent code that is placed "somewhere", e.g. in a main method or another function.

ccpplinux commented 1 year ago

Thanks for clarifications. I have created a new class with name CalculatorTest and then placed those code inside main method of that class and it is working now. Thanks a lot for quick clarifications.

Simn commented 1 year ago

The article should be fixed. I don't like this specific kind of pattern and it sometimes confuses me too when people report issues like that.