Reputation: 117
After having spent a lot of time researching Rails reserved words and implementing, I still have a few questions regarding use.
In my example here, I'll consider the reserved word 'time'. Let's say I want to create a class 'Timepiece'. Is it not recommended to use 'timepiece' because the name begins with 'time'? Would it be recommended to use 'time_piece' or to avoid inserting the reserved word at all? My question here is also about use of the exact reserved word within the class like that.
Thank you.
Upvotes: 0
Views: 762
Reputation: 160271
How is time
a reserved word?
How does time_piece
not use a reserved word like timepiece
does?
In any case, name your classes what they should be named: there's no reason, technical, cultural, semantic, or otherwise, not to use a reserved word inside a class or variable name, even if Time
was the same as time
(it isn't) and time
was reserved (AFAIK it isn't).
Let's instead say you meant Time
, which isn't a reserved word, but is an existing class. If you name something Time
you're re-opening the class. If you name something with Time
in it it's entirely unrelated to Time
itself, and whether or not you should use it as part of the name has more to do with semantics than anything else: again, no reason not to.
Upvotes: 1