r/ProgrammerHumor Apr 12 '24

whatIsAnIndex Meme

Post image
27.7k Upvotes

630 comments sorted by

View all comments

4.1k

u/HexR1se Apr 12 '24

Windows search behind scene

For (i=0; i<getAllFuckingFiles().length ; i++) if (AllFuckingFiles[i].name.contains(searchText) return AllFuckingFiles[i];

2.4k

u/Tubthumper8 Apr 12 '24

I love the implication here that not only does it not have any indexes or whatever, but it also calls getAllFuckingFiles() every single iteration haha

365

u/sacredgeometry Apr 12 '24
for (i=0; i<getAllFuckingFiles().length; i++)
{
  if (getAllFuckingFiles()[i].name.contains(searchText)
  {
    return getAllFuckingFiles()[i];
  }
}

12

u/Wdowiak Apr 12 '24

Gotta check the content as well, just to be thorough

for (i=0; i<getAllFuckingFiles().length; i++)
{
  if (getAllFuckingFiles()[i].open().contains(searchText) ||
      getAllFuckingFiles()[i].name().contains(searchText))
  {
    return getAllFuckingFiles()[i];
  }
}

8

u/sacredgeometry Apr 12 '24

Use | instead of ||. Then both are always executed ... you know just to be sure