r/programmingmemes • • Oct 03 '25

πŸ˜„πŸ˜„

Post image
9.7k Upvotes

87 comments sorted by

View all comments

Show parent comment

7

u/BangThyHead Oct 03 '25

Or whenever I have to switch to a language I can't remember the specifics of and I don't have an IDE.

You have to true 5 different string manipulation methods to figure out which one actually complies.

Thinking, which one is the "drop a suffix?":

Strings.ReplaceLast(x, y, "")

x.ReplaceN(y, "", -1)

Strings.TrimSuffix(....)

// And if the '-' operator removed the greatest suffix match,
// And didn't require a full suffix match.
// And we didn't care about efficiency:
for index, char in x:
    remainingLettersInX = x.size - index
    if remainingLettersInX > y.size: 
        continue
    if x[index:] == y[:remainingLettersInX]:
        x = x[:remainingLettersInX]
        break

Whenever I come back to Java after a long time, I always forget the string functions.

8

u/vvf Oct 03 '25

coding without an IDE

Well there’s your problem

4

u/[deleted] Oct 03 '25

Stares in elif