April 18, 2018 at 12:21 am #14381
Sorry for that newbie question.
What means := ?
I see code and sometime := is used and then other place only =
I know such things like += and so on.April 18, 2018 at 12:38 am #14382
That automatically assigns a type to a new variable, eg.Monkey1234567[crayon-5ce95fd6249a4301786976 inline="true" ]Local a:=0.1 ' a will be a floatLocal b:=1 ' b will be an intLocal c:=New MyClass ' c will be a MyClass objectLocal d:=MyFunction() ' d will be whatever MyFunction returns
… the type being taken from the result of the calculation or call after the = sign.April 18, 2018 at 11:30 am #14393
Ah cool.Thanks for answering.
Have two other questions and i won´t open a new thread for that.
arcList:List<ArcWall> a list names arclist.But what means that inside <> ?
I take a look into documentation but nothing to find.Btw. the search in online docs is terrible. 😉
And are there a “easy to understand” explantation for lambda´s in monkey2?
I don´t know what it does.April 23, 2018 at 9:09 am #14482
arcList:List<ArcWall> creates a list with elements of type ArcWall. So every element in your list is an instance of an ArcWall object.
arcList:List<Int> would create a list where every element is of type Int.
With lambdas you can define functions at places where you call them or use them as parameters. Quite some fancy stuff which you do not necessarily need.
Personally I do not like that “:=” stuff because it just hides what type the object has especially when looking at other’s code. It’s just for lazy guys. 😉 Like the auto type keyword in C++.April 23, 2018 at 6:21 pm #14483
Many thanks….first i learn more C++ and so some questions besome answered alone 😉
But i think for complete newcomers its hard to start from scratch with monkey2 without a good manual.April 23, 2018 at 11:27 pm #14485
Would I be right in saying that a Lambda function is a normal function with the ability to be processed where you write it?
For example, if within the parameter of another function, I needed something to be determined, the result of the Lambda gets passed as the parameter value?April 24, 2018 at 7:26 am #14492
Basically you can see it that way, yes Amon. At some point it’s very handy and useful even though you can create the same results without using lambdas.April 24, 2018 at 9:20 am #14493
Lambdas have access to the local variables, so you avoid writing all the parameters too..
You must be logged in to reply to this topic.