Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Verbosity of code is more of a go thing these days:

  hasThing := false
  for _, v := range stuff {
    if checkForThing(v) {
      hasThing = true
      break
    }
  }
  if !hasThing {
    return false
  }
Java:

  if !stuff.stream().anyMatch(v -> checkForThing(v)) {
    return false;
  }
In the 2020s, loops are the new "goto", too much boiler-plate and ways to subtly be incorrect, much safer to use higher-level collection methods.


    return stuff.stream().anyMatch(this::checkForThing)




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: