Exception handling is hard
-
@Jaloopa said in Exception handling is hard:
ternary statement
Ternaries are good when the two subexpressions are simple enough, but they can easily get out of hand. Like a lot of programming constructs, I guess. There's a lot of things that are good when used judiciously, but awful when overused.
-
That's almost as crazy as Brainf***!
-
@dkf Like the following example (from https://www.codeproject.com/Feature/WeirdAndWonderful.aspx?msg=4327314#xx4327314xx)
byte[] arySend = FetchCommand(cmd.CHANGE_THE_ACTIVE_DISPLAY); int iScreen = this.cboDisplayName.SelectedIndex; iScreen = iScreen < 8 ? iScreen + 1 : (7 < iScreen && iScreen < 10 ? iScreen + 4 : (10 == iScreen ? iScreen + 5 : (11 == iScreen ? iScreen + 10 : (11 < iScreen && iScreen < 16 ? iScreen + 12 : (15 < iScreen && iScreen < 20 ? iScreen + 24 : (19 < iScreen && iScreen < 22 ? iScreen + 45 : (22 == iScreen ? iScreen + 53 : (23 == iScreen ? iScreen + 57 : (23 < iScreen && iScreen < 26 ? iScreen + 65 : (25 < iScreen && iScreen < 28 ? iScreen + 72 : (27 < iScreen && iScreen < 30 ? iScreen + 152 : (30 == iScreen ? iScreen + 160 : (30 < iScreen && iScreen < 33 ? iScreen + 169 : (33 == iScreen ? iScreen + 170 : (34 == iScreen ? iScreen + 171 : (35 == iScreen ? iScreen + 175 : (35 < iScreen && iScreen < 41 ? iScreen + 176 : (41 == iScreen ? iScreen + 203 : (42 == iScreen ? iScreen + 208 : iScreen = iScreen + 212 ))))))))))))))))))); // 43 == iScreen arySend[2] = Convert.ToByte(iScreen); arySend[3] = 0x01; // Refresh screen
-
@BrisingrAerowing
List of applicable ranges with resulting range after sum:-∞..7 -∞..8 8..9 12..13 10 15 11 21 12..15 24..37 16..19 40..43 20..21 65..66 22 75 23 80 24..25 89..90 26..27 98..99 28..29 180..181 30 190 31..32 200..201 33 203 34 205 35 210 36..40 212..216 41 244 42 250 43..∞ 255..∞ I don't see any regular pattern in that. Any ideas what the purpose of the code around this excerpt was?
Also, the last conditional expression itself includes a reassignment of
iScreen
, which means if the code gets there, it would translate toiScreen = iScreen = iScreen + 212
, though the extra assignment would probably get optimized out.
-
From the FetchCommand thing at the start, I think it has to do with changing the currently displayed data on a screen, or changing the screen being used. Not sure though.
-
@darkmatter said in Exception handling is hard:
rpg
I thought that's what that was, just didn't actually program in it so I didn't say anything...
-
@Jaloopa said in Exception handling is hard:
@Hans_Mueller said in Exception handling is hard:
it saves another line, which is a huge plus
Why is that such a bonus? Are you coding in a terminal with only 5 rows visible?
Let me introduce you to my Ti-83+ calculator's programming interface...
-
@Jaloopa said in Exception handling is hard:
@RaceProUK said in Exception handling is hard:
Wait... I got that right?
I dunno, You sounded pretty confident, which suggests you know a lot about it.
@RaceProUK said in Exception handling is hard:
Meh. The early series were fun, before it got super formulaic and spent more time showing what was about to happen and what had just happened than actual mythbusting.
Yeah. When 70% of the episode is re-explaining everything several times, it gets really annoying...
-
@groo said in Exception handling is hard:
@loopback0 said in Exception handling is hard:
@boomzilla said in Exception handling is hard:
DOWNVOTED FOR:
DOWNVOTED FOR DOWNVOTING THAT
Downvoted for downvoting that downvote
Now let's not be silly!
-
@dkf said in Exception handling is hard:
Ternaries are good when the two subexpressions are simple enough, but they can easily get out of hand. And then the murders begin.
-
@boomzilla said in Exception handling is hard:
@dkf said in Exception handling is hard:
Ternaries are good when the two subexpressions are simple enough, but they can easily get out of hand. And then the murders begin.
return simple_enough()? smile: out_of_hand()? available(rock)? death(blunt_force_trauma): available(paper)? death(cuts * 1000): available(scissors)? death(stabbing): death(strangulation): frown;
-
This post is deleted!