Skip to content

How do I make a switch case in cppfront? #1302

Answered by hsutter
MatthieuHernandez asked this question in Q&A
Discussion options

You must be logged in to vote

Cppfront doesn't yet support blocks in inspect alternatives. For now this will work:

exit = inspect selection -> bool {
    is 1 = :()->bool={
        foo();
        return false;
    }();
    is 2 = :()->bool={
        std::cout << "bye" << std::endl;
        return false;
    }();
    is _ = false;
};

To my surprise, one thing I've learned so far with cppfront is that inspect doesn't appear to be one of the popular features. Most other features have generated a lot of usability/correctness feedback like this, and I originally expected much more of that for inspect but inspect has been generally quiet. That usually indicates that people aren't trying to use a feature...? And that could b…

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
7 replies
@JohelEGP
Comment options

@MatthieuHernandez
Comment options

@JohelEGP
Comment options

@hsutter
Comment options

Answer selected by MatthieuHernandez
@MatthieuHernandez
Comment options

@DyXel
Comment options

@ntrel
Comment options

Comment options

You must be logged in to vote
3 replies
@DyXel
Comment options

@JohelEGP
Comment options

@DyXel
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants