RemoveIf example

About Monkey 2 Forums Monkey 2 Programming Help RemoveIf example

This topic contains 7 replies, has 3 voices, and was last updated by  degac 1 year, 5 months ago.

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

    degac
    Participant

    Hi
    I’m trying to understand how to use the method RemoveIf… but without results…

    #11689

    Mark Sibly
    Keymaster

    The parameter for RemoveIf should be a function:

    …you can use a lambda to write the function ‘inline’ too:

    #11698

    degac
    Participant

    Ahhh… many thanks!
    So I can’t pass a value to check (ie: RemoveIf(Check(40)), it must be already defined in the function!
    I misunderstood the meaning/syntax of it!
    I should define a global to change the behavior, same in case of Lambda()

    #11705

    nerobot
    Participant

    Also, you can write & use extension methods, look at example:

    #11713

    degac
    Participant

    o.O wow! this is really… ingenious!
    I would never have though to Extension to resolve the problem! I need to change paradigm… Monkey2 seems have so many interesting way to solve things!

    Thank you very much!

    edit:

    this thing about Stack (or list) and RemoveIf() method & solutions *should* be added to some guide/tutorial/help… It’s a simple thing that shows many features of Monkey2!

    #11729

    Mark Sibly
    Keymaster

    …just wanted to see if this would work really (it does!), getting a bit ‘c++’-ish for my liking though…

    #11762

    nerobot
    Participant

    Function LessThan<T>:Bool( val:T )( cmp:T )

    Wow, two pairs of brackets, it’s an undocumented cheat! 🙂
    And it works. My life will never be the same…

    #11780

    degac
    Participant

    Monkey2 is a … ‘monster’ even for its creator 🙂

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

You must be logged in to reply to this topic.