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

<else-if> support #15

Closed
vitalybe opened this issue Dec 9, 2015 · 3 comments
Closed

<else-if> support #15

vitalybe opened this issue Dec 9, 2015 · 3 comments
Assignees

Comments

@vitalybe
Copy link

vitalybe commented Dec 9, 2015

I often find the need to create an else if. The syntax to do currently is rather ugly:

<If>
    // Condition
</Else>
    <If>
        // First else if
    </Else>
        <If>
            // Second else if
        </Else>
            // Else (first level)
        </If>
    </If
</If>
@AlexGilleran
Copy link
Owner

Yeah I usually find it's easier to create them all on one level and just keep initialCondition && in the front of subsequent ifs.

The thing is that because <If> desugars into a ternary if there's not actually any easy way to do else if. We'd have to either make it so that what I said above was done automatically, or change it so <If> actually desugars into

function() {
    if (cond1) {
         return x;
    } else if (cond2) {
        return y;
    } else {
        return z;
    }
}

@texttechne
Copy link
Collaborator

You can use the ternary operator for else if.

x ? x : ( y ? : z )

@texttechne texttechne self-assigned this Jan 8, 2016
texttechne added a commit that referenced this issue Jan 11, 2016
#15: <else-if> support including restructuring for scalability
@AlexGilleran
Copy link
Owner

I'd say this is fulfilled by <Choose>

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

3 participants