You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Crystal, it's a common convention that method names ending in a ? do not raise, but return nil if the task can not be completed. Other use case for ? is methods that return Bool. E.g. Hash#empty? returns a Bool, indicating whether the Hash has any members. Other use case is String#to_i32 raises if the string don't contain a valid number, but String#to_i32? returns nil if the string is not a valid number. A method with a name ending in ? can confuse programmers if it raises.
E.g. CommentPolicy#show? follows the convention as it returns Bool, and doesn't raise, but CommentPolicy#show_not_found? breaks from the convention as it raises.
Please provide an alias without ? for every method that raises (with the ? version retained for backwards compatibility).
The text was updated successfully, but these errors were encountered:
The methods are not doing their full potential and are not entirely done as they would do more "macro" and magic, at least I planned to. It works fine now, but as it is now, it is not following the convention as you say.
In Crystal, it's a common convention that method names ending in a
?
do not raise, but returnnil
if the task can not be completed. Other use case for?
is methods that returnBool
. E.g.Hash#empty?
returns aBool
, indicating whether theHash
has any members. Other use case isString#to_i32
raises if the string don't contain a valid number, butString#to_i32?
returnsnil
if the string is not a valid number. A method with a name ending in?
can confuse programmers if it raises.E.g.
CommentPolicy#show?
follows the convention as it returnsBool
, and doesn't raise, butCommentPolicy#show_not_found?
breaks from the convention as it raises.Please provide an alias without
?
for every method that raises (with the?
version retained for backwards compatibility).The text was updated successfully, but these errors were encountered: