Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #39952

Re: switch is shared declaration

Path csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: switch is shared declaration
Date Wed, 24 May 2023 12:57:59 -0400
Organization A noiseless patient Spider
Lines 24
Message-ID <u4lfmo$311sp$1@dont-email.me> (permalink)
References <af8aa265-141f-4887-8bae-83a9b2a0f9c1n@googlegroups.com>
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Wed, 24 May 2023 16:58:01 -0000 (UTC)
Injection-Info dont-email.me; posting-host="c39f57dca40f54b1529be7aef7fd9cfe"; logging-data="3180441"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/I7/4DlFku4OYM1nR/qlpKvAsD67fvuGs="
User-Agent Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
Cancel-Lock sha1:tcaPadiZwMr/GiQ0CxGFUi2ULMs=
Content-Language en-US
In-Reply-To <af8aa265-141f-4887-8bae-83a9b2a0f9c1n@googlegroups.com>
Xref csiph.com comp.lang.java.programmer:39952

Show key headers only | View raw


On 5/24/2023 8:15 AM, e.d.pro...@gmail.com wrote:
> I don't use a lot of switches so I hadn't realized this but:
> this is invalid:
> if (1==1) {
>    String s;
> } else {
>    s = "1";
> }
> 
> but this is fine:
> switch (1) {
> case -1:
>    String s;
>    break;
> case 1:
>    s = "1";
>    break;
> }

The entire switch sort of has to be a single scope due to
fall through (no break) being valid.

Arne

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

switch is shared declaration "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-05-24 05:15 -0700
  Re: switch is shared declaration Arne Vajhøj <arne@vajhoej.dk> - 2023-05-24 12:57 -0400
    Re: switch is shared declaration Arne Vajhøj <arne@vajhoej.dk> - 2023-05-24 13:16 -0400
    Re: switch is shared declaration "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-05-24 11:05 -0700
      Re: switch is shared declaration Michael Jung <miju@golem.phantasia.org> - 2023-05-28 12:57 +0200
  Re: switch is shared declaration Marcel Mueller <news.5.maazl@spamgourmet.org> - 2023-05-28 13:31 +0200
    Re: switch is shared declaration Eric Sosman <esosman@comcast-dot-net.invalid> - 2023-05-28 08:36 -0400
      Re: switch is shared declaration Marcel Mueller <news.5.maazl@spamgourmet.org> - 2023-05-28 15:16 +0200
        Re: switch is shared declaration Arne Vajhøj <arne@vajhoej.dk> - 2023-05-28 13:42 -0400
      Re: switch is shared declaration Arne Vajhøj <arne@vajhoej.dk> - 2023-05-28 13:43 -0400

csiph-web