Open omnilinguist opened 8 years ago
@omnilinguist I agree that Planout DSL is missing a few things in that regard
==
in
and/or a set data structure.For beta-testers I was able to avoid the if/else using the dictionary directly :
beta_users = @{ '1242354':'beta', 'qwqewwe':'beta', '00t634986':'beta' };
is_beta = beta_users[user_guid];
But this can be a bit tedious to type, but more importantly it is error prone.
After looking at the language reference and the compiler (https://github.com/facebook/planout/blob/master/planout-editor/js/utils/planout_compiler.js), the way to check for existence of something in a list is not well documented.
One use case I can think of is in case I want to implement whitelists and/or custom targeting. This is a completely fabricated example (though intended to mimic real world use cases), but let's say I want to show a treatment only to users in certain countries, and I am able to pass the country in as an argument. Here is a workaround that worked when quickly playing with the PlanOut editor:
Basically, I just create a dictionary containing (as keys) the values I want to whitelist and set their (dictionary) values to any (non-null) value. This seems like it works, and is probably more performant than having to iterate through a list to check for existence of an element, especially if the list is very long. One could argue that this benefit outweighs the awkwardness of having to use a dictionary with dummy values just to check for simple existence, but seems like a relatively minor issue.
If this seems reasonable to recommend as an approach for this situation, I could make a pull request to update the documentation at some point. Or, does anyone have better ideas in mind?