3 ms·
The example was: ‘if @subscription.supports_feature?(:feature_a)’. In a different language you might deal with more boilerplate (getting some data access objec
by thih9 3y ago
The example was: ‘if @subscription.supports_feature?(:feature_a)’.
In a different language you might deal with more boilerplate (getting some data access object for feature status, passing the db connection, extracting the subscription id, etc), or less clear naming schemes (importing namespaces, aliasing them for convenience, your subscription might come from some one letter temp variable), or something else. At this point the “why” comment might be not that different from the actual ruby code.
Note that we only see one line of ruby code; the parent method name, or the if body would have more context.
- cloverich 3y agoI honestly found that particular example puzzling. I've written code in at least three other languages that would look nearly identical to it. Unless they were referring to the `?`, or perhaps the lack of a trailing `:` / `{` which seems very superficial to me. Maybe the `@` instead of a `self`? Genuinely unsure.
- thih9 3y agoIn general yes, there are other languages where this is easy too. Then again, ruby and rails make it especially easy; perhaps the amount of conventions helps. Other things, like the ‘?’, clean syntax and focus on structure (OO), help too.