this post was submitted on 01 Sep 2023
329 points (96.1% liked)

Programming

17494 readers
121 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] hellishharlot@programming.dev 2 points 1 year ago (1 children)

Not that I'm aware of but that's a condition where you're thinking with an index. What's the difference you're looking for?

[–] indepndnt@lemmy.world 1 points 1 year ago (1 children)

Something like parsing a string that could have command codes in it of varying length. So I guess the difference is, is this a 1-, 2-, or 3-character code?

I have something like this in a barcode generator and I keep trying to find a way to make it more elegant, but I keep coming back to index and offset as the simplest and most understandable approach.

[–] hellishharlot@programming.dev 1 points 1 year ago

So you could generate lists of 1, 2, and 3 character code items rather than looking at index +1 or something.