Skip to content

CAT 015

unurgunite edited this page Jul 11, 2026 · 3 revisions

CAT-015 — Struct vs Class heuristic

Severity: info | Confidence: medium | Auto-fix:

Description

Struct vs Class heuristic — Using class for small value objects allocates on the heap. Prefer struct for immutable, small data objects.

Bad code

class Point
  getter x, y
  def initialize(@x : Int32, @y : Int32); end
end

Benchmark

Note

See bench results at bench/cat-015/

Clone this wiki locally