635
Zero to Hero in 1 hour (sh.itjust.works)
you are viewing a single comment's thread
view the rest of the comments
[-] db2@sopuli.xyz 41 points 2 years ago* (last edited 2 years ago)

15 steps. You're not counting the top, and the bottom is step 0 and we all know counting starts there.

[-] jerome@kbin.social 35 points 2 years ago
[-] GuybrushThreepwo0d@programming.dev 45 points 2 years ago

We are on a programming sub of a federated and open source reddit clone. We are all nerds.

[-] ripcord@kbin.social 15 points 2 years ago

I assume it was meant as a compliment.

[-] jerome@kbin.social 2 points 2 years ago

(i said it with love)

[-] UnRelatedBurner@sh.itjust.works 5 points 2 years ago

sometimes i start my iterator with = -1. As I only +=1 it with a condition and I know that it will return true on the first cycle. I'll chuck array[iterator] and need it to be 0 to start with ofc.

I just have no idea how to not do this, but it looks so bad, i need a i8 instead of a u8 at least because of this

[-] Kache@lemm.ee 5 points 2 years ago

What? My intuition is there's always gotta be some equivalent nicer refactor that could do away with such an awkward construct.

In what kind of situation would that be totally unavoidable?

[-] UnRelatedBurner@sh.itjust.works 1 points 2 years ago

I could tell you my recent cenario, but it wouldn't get us anywhere. because I know that it's avoidable, but it'd take for me to run a different logic for only first element of my array. which is doable, but it'd make the code like 5 extra lines longer, harder to read/follow. But I just simply choose to put -1 and boom it's fixed, just works.

another solution would be (without context) is to add one more variable and one more check to my foreach, but that takes more memory and cpu, I usually choose the i = -1, it's ugly but not as ugly as other solutions would be

[-] darcy@sh.itjust.works 2 points 2 years ago* (last edited 2 years ago)

thats great unless you want i to be an unsigned integer

edit: oops u already mentioned that

[-] KIM_JONG@lemmy.world 2 points 2 years ago

I hope I never have to see this code.

[-] UnRelatedBurner@sh.itjust.works 1 points 2 years ago

lucky, I forgot it

[-] UnRelatedBurner@sh.itjust.works 1 points 2 years ago

sending it asap (when I get home)

this post was submitted on 05 Sep 2023
635 points (97.7% liked)

Programmer Humor

24957 readers
1818 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS