MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/p2m0hg/if_in_doubt_use_inline_if_statements/
r/badcode • u/[deleted] • Aug 11 '21
9 comments sorted by
12
I love how right ? parts of code look like he's asking for someone's opinion.
right ?
2 u/[deleted] Aug 12 '21 ahahayeahit's for positioning the edge dirt textures shown here: https://i.imgur.com/XbY28D7.png
2
ahaha
yeah
it's for positioning the edge dirt textures shown here: https://i.imgur.com/XbY28D7.png
21
Thats a ternary (conditional) operator.
4 u/[deleted] Aug 11 '21 I don’t see the need to nitpick semanticsBut, https://docs.oracle.com/cd/E57185_01/IRWUG/ch21s03s01s02.html oracle does agree with meBoth mean the same thing 7 u/gu3st12 Aug 12 '21 They're not quite the same, especially in how ternaries resolve when they're nested can catch people by surprise. 3 u/MrMelon54 Aug 12 '21 try using brackets that tends to resolve that issue 4 u/AlFasGD Aug 12 '21 What OP meant is that the docs themselves call the ternary operator an "inline if", though in reality what an inline if is is completely different indeed.
4
I don’t see the need to nitpick semantics
But, https://docs.oracle.com/cd/E57185_01/IRWUG/ch21s03s01s02.html oracle does agree with me
Both mean the same thing
7 u/gu3st12 Aug 12 '21 They're not quite the same, especially in how ternaries resolve when they're nested can catch people by surprise. 3 u/MrMelon54 Aug 12 '21 try using brackets that tends to resolve that issue 4 u/AlFasGD Aug 12 '21 What OP meant is that the docs themselves call the ternary operator an "inline if", though in reality what an inline if is is completely different indeed.
7
They're not quite the same, especially in how ternaries resolve when they're nested can catch people by surprise.
3 u/MrMelon54 Aug 12 '21 try using brackets that tends to resolve that issue 4 u/AlFasGD Aug 12 '21 What OP meant is that the docs themselves call the ternary operator an "inline if", though in reality what an inline if is is completely different indeed.
3
try using brackets that tends to resolve that issue
What OP meant is that the docs themselves call the ternary operator an "inline if", though in reality what an inline if is is completely different indeed.
6
Image Transcription: Code
@Override public void render(int x, int y, String tex, boolean isEdge, boolean right) { game.getSpriteBatch().draw(game.getAsset(tex, Texture.class), x, y, getTileWidth(), getTileHeight()); if (isEdge) { game.getSpriteBatch().draw(game.getAsset(right ? dirtEdgeTexture_right : dirtEdgeTexture_left, Texture.class), right ? (float) (x + getTileWidth() / 1.5) : (float) (x - getTileWidth() / 1.5), y, getTileWidth(), getTileHeight()); } }
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
2 u/[deleted] Aug 11 '21 Thhhannkkkkkk ya :D
Thhhannkkkkkk ya :D
12
u/silverweaver Aug 12 '21
I love how
right ?parts of code look like he's asking for someone's opinion.21
u/bugqualia Aug 11 '21
Thats a ternary (conditional) operator.
6
u/ElliePlays1 BadTranscriber...wait no Aug 11 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!