I’ve just made another simple example of a set of properties that you can use on lists: $allkeys and $allkeysSet, alongside the other uncommonly known properties.

UPDATE: It turns out there’s a better alternative to $allKeys and $allkeysSet, which is to use public properties such as .getChildNames, .getPropertyKeys, and .getFunctionNames instead so you get almost no chance of your code being non-functional by the “implementation changes”.

Please feel free to provide better usage examples of this particular property if you have one!

  • @[email protected]M
    link
    fedilink
    English
    3
    edit-2
    2 months ago

    Those are actually ‘private’ properties, but it was poor thinking on my part to leave them exposed for general use like that, and I’ve seen others use them before, so I won’t move/change them at this point. Still, definitely better to use the “public” variants mentioned here: https://perchance.org/advanced-tutorial

    Namely: getChildNames, getPropertyNames, getFunctionNames, and getAllKeys properties.

    It’s my bad for not documenting these more clearly somewhere, and for not properly restricting user code from accessing the engine’s internal stuff.

    I try to take backwards compatibility of perchance engine stuff very seriously, just like web standards, but if you reach too deep into the engine, especially things that aren’t publicly documented, then there’s a big risk of your code relying on “implementation details” (that could change later) instead of “public APIs”. So always stick to stuff that is officially documented somewhere, because then you’ve got a guarantee of backwards compat. And feel free to ask about things that you discover that aren’t documented in the official tutorial/examples/etc, or ask for new features, of course!

    • BluePowerOP
      link
      English
      2
      edit-2
      2 months ago

      Oh! Apologies I found these “hidden” properties while playing with the console and randomly used that as a source to the example. I didn’t even know these properties exist on Perchance, so I might change these examples to reference to these properties. duh

      I also found existing documentations on how these properties work, such as on the Perchance Snippets page and the Other Properties and Creating Perchance Lists article in the Advanced Generator Building Concepts section on the Hub. (I also randomly found that getPropertyKeys is used on what-blank-are-you-template while searching for that online.)

      But thanks for the explanation, though.