4 ms·
I write a lot of Ruby for work, but I’m not sure what “shapes” are - do you have any good reference where I could start reading?
by mwint 5y ago
I write a lot of Ruby for work, but I’m not sure what “shapes” are - do you have any good reference where I could start reading?
- jez 5y agoThey're basically Hash literal types in Ruby. It's what TypeScript calls object types: https://www.typescriptlang.org/docs/handbook/2/objects.html https://www.typescriptlang.org/docs/handbook/2/objects.html (Ruby and JavaScript mean slightly different things by the word "object" so we chose a different word.) Flow also has a distinction between exact and inexact object types: https://flow.org/en/docs/types/objects/ https://flow.org/en/docs/types/objects/ where the difference is whether other, unspecified fields are allowed to hide in the object, or whether values of type `{foo: number}` must have only the `foo` field, and no other fields.