News for hackers. Stuff that matters.
Re:Java's records, Lombok's data, and Kotlin's data classes by _old_dude_ on Friday May 07, 2021 @02:55PM (#27079509)
I wonder why, unlike a Java record, in Kotlin a data class annotated with @Record can not be local.

Being able to use local records is a useful feature in particular in unit tests.

  @Test
  void testPoints() {
     record Point(int x, int y) {}
     ...
  }
Re:Java's records, Lombok's data, and Kotlin's data classes by tadfisher on Friday May 07, 2021 @10:11PM (#27083033)
I don't see the point; you're not testing code that depends on Point, as it's local, so `x to y` (i.e. `Pair(x, y)`) would work just as well.

If there's a particular language feature records enable that Kotlin doesn't with ordinary data classes in this case, I'd love to see it.