Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CL - List and Dict Initializers #216

Open
AutumnThyme opened this issue Dec 24, 2024 · 0 comments
Open

CL - List and Dict Initializers #216

AutumnThyme opened this issue Dec 24, 2024 · 0 comments

Comments

@AutumnThyme
Copy link
Collaborator

Similar to C#, JS, and Python, we should allow collections to be initialized with values.

class Main
{
    # Public variable should have a corresponding default array entry in Mode/Map editor veiw using JSON as the format.
    ModeVariable = List();

    # Second public variable uses a gameobject selector, on running, all gameobjects should be added to the list (or all ids if that prior isn't feasible).
    @MultiGameObjectSelector
    GameObjectVariable = List();

    # Private variables can use initializers. (Use whatever version is picked from the Init function).
    _privateVariable1 = List(['a', 'b', 'c']);

    function Init()
    {
        # Implement one of the following versions of list initializers.

        # version 1 syntactic sugar replaces [expr, expr, expr] with List(expr, expr, expr, ...) -> must modify list to have a secondary constructor that takes in objects
        localVariable1 = ['a', 'b', 'c'];
        localVariable2 = List(['a', 'b', 'c']);

        # version 2 likely use syntactic sugar to replace List() { expr, expr, expr } with List(expr, expr, expr, ...) -> must modify list to have a secondary constructor that takes in objects
        localVariable3 = List() { 'a', 'b', 'c' };
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant