It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.
For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.
/u/anyfactor, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.
Could happen in threaded code or if the body of the loop removes an element from the collection and the iterator is.... But unlikely this is the consideration (a design that requires such checks is bad), and if so should be carefully commented.
"dono" means "owner" in portuguese, so that for loop is actually something we could see in brazil ("for owner in owners"). would still be a bad code tho.
It depends on the language. In C# it's essentially a higher level array - you can append to the list with .add, which increases the list's length at runtime.
It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.
For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.
/u/NetherFX, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.
164
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Mar 04 '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!
5
u/[deleted] Mar 04 '21
Would have made more sense as "dunno" ... or "donut"
696
u/polaris0312 Mar 04 '21
ah yes, the Schrodinger's dono
281
u/charliesname Mar 04 '21
You dono that dono is in donos?
182
u/yonatan8070 Mar 04 '21
# Check if computer is drunk67
u/MAKAPOH57 Mar 04 '21
3am, going to bed, thank you bad code post for sending me to bed
34
u/Halpaviitta Mar 04 '21
To be in dono or not to be in dono
26
u/KrisPiBean Mar 04 '21
That's analogous to opening a matchbox and looking for a match that is not in the matchbox
19
u/[deleted] Mar 04 '21
I dono, man, this looks bad.
25
u/SloPr0 Mar 04 '21
Sometimes this actually has a very niche use case, as protection against some other thread modifiying the array as the loop is executing.
Such things can happen for example in Lua, where the end condition in a for loop is only evaluated once, before the loop starts
Outputs
instead of 1-5
So if an element at an index gets removed by another thread simultaneously, it could try to access an invalid element
TL;DR: Don't use Lua
7
u/NetherFX Mar 04 '21
What a tongue twister
7
u/bilcox Mar 04 '21
I want to see the code block that actually handles that case.
8
u/anyfactor Mar 05 '21
3
u/CarterNotSteve Mar 04 '21
If yes! Then no!
3
u/[deleted] Mar 05 '21
Quantum computing
3
u/[deleted] Mar 05 '21
This is the most hilarious post I’ve seen on here. It definitely helps that “dono” is a funny as shit word. I wanna know what it means here
2
u/isunktheship Mar 05 '21 edited Mar 05 '21
I dono'ed when I should have dono'ed
1
u/TxnSemantics Mar 04 '21
Could happen in threaded code or if the body of the loop removes an element from the collection and the iterator is.... But unlikely this is the consideration (a design that requires such checks is bad), and if so should be carefully commented.
1
u/ekolis Mar 05 '21
var datas2 = datas.Where(...);1
u/MrPNGbr Mar 05 '21
"dono" means "owner" in portuguese, so that for loop is actually something we could see in brazil ("for owner in owners"). would still be a bad code tho.
1
u/perfecttoasts Mar 05 '21
I sometimes do stuff like that.
Like: okay but what if..... What if the code doesn't do what it says it should do? Better double.check!
1
u/[deleted] Mar 13 '21
Plot twist: it finds a “dono” and the fabric of reality tears apart.
1
u/GaiusCosades Apr 17 '22
I use semaphores to prevent race conditions but whatever works for you mate...
1
u/Spanktank35 Dec 29 '22
Me debugging
-1
u/Gyro_Zeppelin Mar 04 '21
I don't understand a single word
0
u/xAmyne Mar 04 '21
didnt u dono ?