Breaking: remove String#tokenize core extension #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This was deprecated in v0.4.0 (ee08d06) so it gets removed in the next major release, v0.5.0, which I intend to release soon.
To recap: please use
Groupie.tokenize(string)
instead ofstring.tokenize
.Why remove a core extension? 10 years ago (when I added it) they were more commonly accepted (we were still in the early days of Ruby). These days it's less common in the community to use core extensions, especially for trivial things.
Ruby is a language that allows amazing levels of expressiveness due to core extensions being foundational for domain specific languages, but the dark side is that when used poorly it only makes code harder to understand and debug.
This very example: the deprecated code makes it hard to understand where tokenize is implemented. Is it part of Ruby's core library? Is it part of a core extension library such as ActiveSupport? Is it part of one of the 200+ gems that a large project might have? You simply don't know unless you have a smart IDE that understands it for you, or you happen to be the engineer that added the library and thus knows about it (but your colleague is still dumbfounded).
In contrast, the new default makes it very explicit where the tokenize function comes from. Being able to understand and reason about code is something I've come to appreciate more after having jumped into multiple projects that other people had created and thus I was the one that lacked context where things came from.