Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Problem with case in AppGameKit

Author
Message
Sabinay
7
Years of Service
User Offline
Joined: 30th Apr 2016
Location:
Posted: 18th May 2016 15:09
I have multiple array of different size. I have to select one array at a time and implement getPointerpressed() on that array next time another array. So i use case in do loop but the is not compiling showing compiling bar for some time them it makes device hang. Can you give me some solution?
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th May 2016 17:14
Can you show us some code, it should be easy to diagnose.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 28th May 2016 08:20
What are the advantage of CASE compared to IF?
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 28th May 2016 10:51
I don't know about the performance advantages, but for more than a couple of conditions, CASE is much more readable.
It also automatically applies the rule of programming that as few lines as possible should be executed. A CASE statement ignores all alternative cases once a valid one is found.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 28th May 2016 19:27
Quote: "A CASE statement ignores all alternative cases once a valid one is found."


Is that not the same as an If/Else If?
Using AppGameKit V2 Tier 1
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th May 2016 00:53
Yes, but If / Else If is not as elegant, especially after the second one. Again I don't know the full technicalities, but I can see that a series of Else Ifs will have to unwind itself on the stack after resolving the logic. Additionally, a Case statement can be rationalised much better in the compiler, because all CASEs have equal weighting. In the If/Else construct, the compiler has to take your logic as it stands, because there may be dependencies within the ladder of statements.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2024-03-01 07:31:05
Your offset time is: 2024-03-01 07:31:05