825
Leave it alone (lemmyf.uk)
you are viewing a single comment's thread
view the rest of the comments
[-] magic_lobster_party@kbin.social 4 points 1 year ago* (last edited 1 year ago)

One benefit of using dropwhile is that (with a bit of practice) it can actually be easier to read than a for loop. All for loops look similar. You need to read the for loop line by line to understand what it really do.

With dropwhile (or map, filter and reduce), it’s immediately obvious it will drop all elements until a certain condition turns false.

[-] stockRot@lemmy.world 2 points 1 year ago
[-] kogasa@programming.dev 3 points 1 year ago* (last edited 1 year ago)

Skip. As in, "drop the first 5 elements of this iterable." dropwhile is "drop each element until the given predicate is satisfied." It's really not that obscure, I dunno what the original commenter is on about

[-] docAvid@midwest.social 2 points 1 year ago

Yeah, I'm not even a python dev, I knew what dropwhile did immediately from the name. Some people just don't want to learn anything new, ever.

this post was submitted on 06 Jan 2024
825 points (100.0% liked)

Programmer Humor

33243 readers
1022 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS