Playing with first class functions

About Monkey 2 Forums Monkey 2 Programming Help Playing with first class functions

This topic contains 19 replies, has 5 voices, and was last updated by  nerobot 1 year, 4 months ago.

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #12092

    Mark Sibly
    Keymaster

    GetValue <T>:T ( key:String,value:T=Null )

    I quite like this, but I thought your original point was that GetValue should *fail* if ‘key’ can’t be found? I actually like this idea. Perhaps we could have both, eg:

    In this case, it’d be possible to get exactly current behaviour by using ‘GetValue(key,Null)’ but it’d also pick up existing bugs where you expected something to be in a Map but it wasn’t.

    #12095

    nerobot
    Participant

    Yes, I like what you said in the latest post.

    And some changes to docs for these methods where you explain that Null is context specific. Maybe even to create own docs page for Null and place references here from other pages.

    What happen if we compare ‘default null’ first class function with keyword Null?

    If GetValue ( "test",Null )=Null

    Genarally, .Contains () is our big friend. 🙂

    #12096

    nerobot
    Participant

    What happen if we compare ‘default null’ first class function with keyword Null?

    The answer is – first class function is null until have no assigned values.

    Example app:

    Output:

    Also I found that mx2cc allow us to write weird code:

    Is this Null value will generate anonimous new instance or simple will do nothing?

    I think the answer is the second case – do nothing. If we have empty / null f and write f+=Null then f still is null.

    #12097

    Mark Sibly
    Keymaster

    Also I found that mx2cc allow us to write weird code:

    That *is* pretty weird, but it sort of makes sense (to me). I guess it’s a bit like x+=Null where x is an int. I can live with this wrinkle. All other results are what I’d expect (and what I think people would intuitively expect) anyway.

    #12098

    nerobot
    Participant

    I tried it just for testing because we talk about Nulls here.

    And I can live with that too. 🙂

Viewing 5 posts - 16 through 20 (of 20 total)

You must be logged in to reply to this topic.