Properties in interfaces

About Monkey 2 Forums Monkey 2 Development Properties in interfaces

This topic contains 4 replies, has 3 voices, and was last updated by  Samah 2 years, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #875

    Samah
    Participant

    So, how do I define a property in an interface, but enforce that it must or must not have a setter?  In Monkey-X I could explicitly define one or both, but MX2 has the property bunched into a single block.

    Edit: Monkey-X example:

    Monkey 2 example?

     

    #883

    Mark Sibly
    Keymaster

    Just leave out the ‘End’…

     

    #884

    Samah
    Participant

    Thanks.  It seems a bit awkward that you need to define an argument to the setter.  Languages like C# and Swift give you an implicit variable called newValue
    I wish it had a didSet/ willSet pair too. 🙂

    #885

    therevills
    Participant

    Leave out the ‘End’…. which ‘End’?

    Getter/Setter:

    Getter Only:

    Did I miss something here?

    #887

    Samah
    Participant

    @therevills: That’s basically what I wanted.
    Edit: Ooohhh putting an @ creates a link to the user’s profile. 😀

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

You must be logged in to reply to this topic.