🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7940

Re: Language puzzle

#7940
From: Valentino Kyriakides
Date: Wed, 02 May 2001 20:00
36 lines
1688 bytes
John McGrath [TeamB] <ng-b@JPMcGrath.net> schrieb in im Newsbeitrag:
3aef3645_1@dnews...
> Here is an interesting little language question:
>
> Are the following two methods equivalent?
>
>     String booleanString( boolean b ) {
>         String s;
>         if ( b ) {
>             s = "true";
>         } else {
>             s = "false";
>         }
>         return s;
>     }
>
> And:
>
>     String booleanString( boolean b ) {
>         String s;
>         if ( b ) s = "true";
>         if ( !b ) s = "false";
>         return s;
>     }

Yes and no!

No, because their inner used scoping for the "String s" is different. I
think, thus the second ones String should been initialized first.

Yes, in that when the seconds String is first properly setup (initialized)
they will produce/have the same results/effects.


Greetings Valentino
Technical Details
Message-ID: <3af06553$1_1@dnews>
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3aef3645_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,b65cd5c59c7b0e70
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-05-02 13:00:05 PST
From: "Valentino Kyriakides" <vkyr@ision.net>
Newsgroups: borland.public.jbuilder.java.language
References: <3aef3645_1@dnews>
Subject: Re: Language puzzle
Date: Wed, 2 May 2001 22:00:05 +0200
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
NNTP-Posting-Host: 195.180.208.149
Message-ID: <3af06553$1_1@dnews>
X-Trace: dnews 988833107 195.180.208.149 (2 May 2001 12:51:47 -0700)
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews