Talk:Appearance rates: Difference between revisions
Jump to navigation
Jump to search
imported>Bale Created page with 'StDoodle, regarding our recent discussion regarding the switch statement: How's this for a nice use of it to increase code readability? Incidentally, there was a bug in the origi…' |
imported>Bale No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
StDoodle, regarding our recent discussion regarding the switch statement: How's this for a nice use of it to increase code readability? Incidentally, there was a bug in the original code -- it didn't pick out bosses. --[[User:Bale|Bale]] 05:00, 6 May 2010 (UTC) | StDoodle, regarding our recent discussion regarding the switch statement: How's this for a nice use of it to increase code readability? Incidentally, there was a bug in the original code -- it didn't pick out bosses. --[[User:Bale|Bale]] 05:00, 6 May 2010 (UTC) | ||
It still doesn't clarify that one can use completely "unrelated" variables in the individual case statements. Ie, you could do the following (if I'm not mistaken): | |||
{{CodeSample| | |||
code= | |||
<syntaxhighlight> | |||
int a; | |||
//stuff may happen to a | |||
boolean [string] blah; | |||
//blah may get populated | |||
foreach x in blah { | |||
switch { | |||
case x == "hello": | |||
print("kitty"); | |||
break; | |||
case a > 9000: | |||
print("spare me the memes"); | |||
break; | |||
//etc. | |||
} | |||
} | |||
</syntaxhighlight>}} | |||
--[[User:StDoodle|StDoodle (#1059825)]] 15:58, 6 May 2010 (UTC) | |||
No? I tested for mob == $monster[none] and I tested for freq > 0. Those are different variables. --[[User:Bale|Bale]] 21:27, 6 May 2010 (UTC) |
Latest revision as of 21:27, 6 May 2010
StDoodle, regarding our recent discussion regarding the switch statement: How's this for a nice use of it to increase code readability? Incidentally, there was a bug in the original code -- it didn't pick out bosses. --Bale 05:00, 6 May 2010 (UTC)
It still doesn't clarify that one can use completely "unrelated" variables in the individual case statements. Ie, you could do the following (if I'm not mistaken):
int a;
//stuff may happen to a
boolean [string] blah;
//blah may get populated
foreach x in blah {
switch {
case x == "hello":
print("kitty");
break;
case a > 9000:
print("spare me the memes");
break;
//etc.
}
}
--StDoodle (#1059825) 15:58, 6 May 2010 (UTC)
No? I tested for mob == $monster[none] and I tested for freq > 0. Those are different variables. --Bale 21:27, 6 May 2010 (UTC)