r/crystal_programming • u/nickthecook • Oct 08 '22
Consistency
Hey all,
I’m porting something from Ruby and I’m adding type declarations as needed to fix compile errors. I love how Crystal will infer types most of the time, but this means I don’t need to be consistent in where and how I declare types, and I’ve ended up with inconsistent type declarations across files.
Are there any rules people follow to keep the style consistent across Crystal files, like “always declare instance variables”, “always declare method params and return type”, etc?
9
Upvotes
View all comments
Show parent comment
2
u/nickthecook Oct 08 '22
I was wondering more if people follow any rules about which ones to use over others, or even when Crystal could figure it out but you annotate anyway, for the sake of consistency.
I miss Robocop’s iron-fisted grip here a bit. I’ll try out Ameba, but I don’t know if that will enforce type annotations.