Before you mark this as a duplicate of "What is the colon operator in Ruby?", read the question (just being preemptive). I'm not asking about what the colon actually does.
I was recently trying to come up with a clever solution to "Convert string to symbol/keyword". My first thought was to overload the colon operator for the String class, just like Ruby does for the +
method on String (I'm aware of the potential downsides of doing that). But I discovered that the :
is not simply an overloadable operator of String.
The first result on Google for "ruby operators" does not show the colon as an operator. And I can't find any sources that claim it is an operator. I suppose it would fall under the same category as the hashrocket (=>
) but I don't know what you would call these.
So what is this special colon character classified as? And can you point to its definition in the Ruby source where it can potentially be altered?