What means := ?

This topic contains 7 replies, has 5 voices, and was last updated by  abakobo 2 months, 3 weeks ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #14381

    darky
    Participant

    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.

    #14382

    DruggedBunny
    Participant

    That automatically assigns a type to a new variable, eg.

    [/crayon]

    … the type being taken from the result of the calculation or call after the = sign.

    #14393

    darky
    Participant

    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.

    #14482

    Xaron
    Participant

    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++.

    #14483

    darky
    Participant

    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.

    #14485

    Amon
    Participant

    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?

    #14492

    Xaron
    Participant

    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.

    #14493

    abakobo
    Participant

    Lambdas have access to the local variables, so you avoid writing all the parameters too..

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.