by blarnopre · 3y ago · 0 comments
I know, I know, OStruct does this but it's not the thing that gets built from hash literals so it's less convenient.
It's a minor quibble
Foo = Struct.new(:a, :b, keyword_init: true) do
def frobz
...
end
end
Structs are quicker to instantiate than classes but slower to call methods on, so if you instantiate a lot but seldom call they're great. Otherwise a class is better.