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

Implement switch-statements #70

Closed
skx opened this issue Sep 13, 2020 · 0 comments
Closed

Implement switch-statements #70

skx opened this issue Sep 13, 2020 · 0 comments
Assignees

Comments

@skx
Copy link
Owner

@skx skx commented Sep 13, 2020

I want to allow this to succeed:


function test( name ) {
  switch( name ) {
    case /^steve$/i {
       printf("I'm a regexp\n");
    }
    case "Steven" {
	printf("I know you!\n" );
    }
    default {
	printf("I don't know who you are\n" );
    }
  }
}

test( "Steve" );    // Regexp match
test( "Steven" );   // Literal match
test( "Bob" );      // Unhandled case

NOTE: I explicitly use blocks here, because fall-throughs are evil :)

@skx skx self-assigned this Sep 13, 2020
@skx skx mentioned this issue Sep 13, 2020
@skx skx closed this in #71 Sep 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant
You can’t perform that action at this time.