Skip to content

CAT 015

unurgunite edited this page Jul 11, 2026 · 3 revisions

CAT-015 — Struct vs Class heuristic

Field Value
Severity info
Confidence medium
Auto-fix

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

Clone this wiki locally