3 ms·
Records being allowed in methods has been great for me when doing things like path finding. Makes it easy to write something like: record Node(int cost, in
by papercrane 2y ago
Records being allowed in methods has been great for me when doing things like path finding. Makes it easy to write something like:
record Node(int cost, int row, int col){}
var pq = new PriorityQueue<Node>(Comparator.comparingInt(Node::cost));
- gf000 2y agoThis is actually a natural extension of classes being allowed inside, which is not well-known for some reason. Nonetheless, I also really like this feature with records.
- roncesvalles 2y agoIt's allowed because Record automatically implements methods called cost(), row(), and col().