HackerTrans
TopNewTrendsCommentsPastAskShowJobs

beantaxi

no profile record

comments

beantaxi
·2 anni fa·discuss
Since you asked, I find the terse version to be completely unreadable*. If I wanted to understand it, I’d end up writing out all the steps for myself anyway.

There’s an asterisk here because you cherrypicked a function that is already widely known and understood. All we really need to understand that function is its name. If you chose complex niche business logic, or The Wave Function, it would have made for a more fair and instructive example.
beantaxi
·2 anni fa·discuss
They might indeed. Or

  a := []int{1,2,3,4}
  it       := slices.All(a)
  itRev    := slices.Reverse(it)
  itMap    := slices.Map(it)
  itFilter := slices.Filter(it, func(i int) bool { return i % 2 == 0 })
  slices.ForEach(it, func(i int) { fmt.Println(i) })
No fun to write. Is it better to read? Yes, if you want to know exactly what's going on. Not really, if you are skimming through a lot of code, you're used to cruising through chains of func calls, and the above feels like speed bumps.
beantaxi
·2 anni fa·discuss
Sounds pretty interesting. If you were to write up how you tested this, I’d definitely read it.