New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Char#code_point method #6035
Conversation
We have a no-aliases convention in Crystal, so we can't have both |
@ysbaddaden Hm, I looked into source for Char and found for example:
or other aliases, like (in iterable.cr):
Is this a new convention or...? |
Those aren't aliases. class Foo
def name_foo
# ...
end
def name_bar
name_foo
end
end An alias serves no other purpose but to provide an alternate name for a single function. The methods you show call different functions / wrap / shortcut to other behavior, not just "rename" a method. |
We don't want aliases but it'd still be a valid proposal to rename On the other hand |
I think in some rare cases, aliases are useful - such example would be TempFile:
Here unlink is an alias to delete. I believe that we should keep
unapplicable here. I believe that when you want to get code point of char, the fact that it can be get using method |
If we keep |
I understand - the crucial point of information here is that all existing aliases are legacy code. I'm closing this PR, and I would be thrilled to help hunt these lost aliases down - will be making PRs if I found any (like #6036). |
When we use
Char
, often use case is to get it's code point.However in Crystal there isn't
code_point
method on Char, onlyord
. This PR addscode_point
method (which is intuitive), that returns code point of given char (same asord
).I've included specs and documentation for this method.