fast-ruby icon indicating copy to clipboard operation
fast-ruby copied to clipboard

`String#match` vs `String#scan`

Open AlexWayfer opened this issue 5 years ago • 3 comments

Hello.

These methods are pretty similar.

I've done some benchmarks and figured out that match is twice faster than scan.

I can try to make a PR, but not sure do we need for it here.

AlexWayfer avatar Aug 20 '20 14:08 AlexWayfer

Friendly reminder: String#match outputs a MatchData while String#scan outputs an Array.

ParadoxV5 avatar Aug 20 '20 22:08 ParadoxV5

Friendly reminder: String#match outputs a MatchData while String#scan outputs an Array.

Yes, but they're similar, but an outside code will be different for the same input data (String and Regexp). But the point of comparison of these approaches is they complete the similar goal.

AlexWayfer avatar Aug 20 '20 22:08 AlexWayfer

@AlexWayfer If you're still interested in this, feel free to open a PR. All you need to do is follow the guidelines in the CONTRIBUTING.md.

mateusdeap avatar Nov 07 '22 18:11 mateusdeap