Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Return 2 values from a function
Message
De
17/10/2008 10:29:43
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
17/10/2008 10:16:23
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01355203
Message ID:
01355589
Vues:
34
>>I think Hugo got his code exactly right as it couldn't have returned anything but False so why bother with all the extra code.
>
>Please recheck the codes. You got the code wrong too.
>They are too much different making me to think multiple returns or single return doesn't do any contribution to readability and maintainability;)
>
>
>Cetin

Well that could be so lets review.
>>Function SomeMethod() AS Boolean
>>
>>   Dim result as Boolean = False
"result" starts out false here
>>
>>   If FirstCheck() = False Then
>>      result = False
then if FirstCheck() is true, nothing happens but if it is false, "result" is still false

>>   ElseIf SecondCheck() = False Then
>>      result = False
>>    Else
>>        'Other code here
>>   EndIf

now if SecondCheck() is true, no change to "result" but if it is false, then "result" is still false.  No indication what Else does.
>>
>>   Return result
Here we might as well just return false.
>>      
>>End Function
>>
What did I get wrong?
Tim
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform