multiple arguments in switch?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JS

    #1

    multiple arguments in switch?

    As I can remember this is not allowed in java:

    int x, y, z;

    switch(x,y,z){
    case 1,2,3:
    System.out.prin tln("Hep");
    break;
    }


    But what about in JavaScript, or are there some other kind og syntax for
    switch??


  • Richard Cornford

    #2
    Re: multiple arguments in switch?

    JS wrote:[color=blue]
    > As I can remember this is not allowed in java:
    >
    > int x, y, z;
    >
    > switch(x,y,z){
    > case 1,2,3:
    > System.out.prin tln("Hep");
    > break;
    > }
    >
    >
    > But what about in JavaScript,[/color]

    If the - int - was - var - and the - System.out.prin tln - referred to a
    function object then the rest of the syntax is fine in javascript. It is
    extremely unlikely that that a list expression used as the Expression
    for the - switch - statement, or the Expression for the - case - clause,
    will do anything useful.
    [color=blue]
    > or are there some other kind
    > og syntax for switch??[/color]

    By "some other kind og syntax" do you mean something that will do what
    you want to do? That will inevitably depend on what it is you are trying
    to do.

    The FAQ for this group includes guidance on the asking of questions. You
    would benefit form reading it.

    <URL: http://www.jibbering.com/faq >

    Richard.


    Comment

    • alu

      #3
      Re: multiple arguments in switch?

      Could i recommend that you download the old-but-still-ever-so-easy-to-read
      netscape client-side javascript reference manual?
      It will provide the answer to most of your everyday questions within a few
      seconds.
      ftp://docs-pdf.sun.com/816-6408-10/816-6408-10.pdf

      -alu


      "JS" <dsa.@asdf.co m> wrote in message news:d7gbpc$1r6 $1@news.net.uni-c.dk...[color=blue]
      > As I can remember this is not allowed in java:
      >
      > int x, y, z;
      >
      > switch(x,y,z){
      > case 1,2,3:
      > System.out.prin tln("Hep");
      > break;
      > }
      >
      >
      > But what about in JavaScript, or are there some other kind og syntax for
      > switch??
      >
      >[/color]


      Comment

      Working...