From: "Eregon (Benoit Daloze) via ruby-core" Date: 2026-03-18T08:37:09+00:00 Subject: [ruby-core:125067] [Ruby Feature#21932] `MatchData#get_int` Issue #21932 has been updated by Eregon (Benoit Daloze). I think returning 0 when the group isn't parseable as a number seems bad behavior. At least if I would use this method, I would expect two things of it: * It returns the Integer value of that group, without needing `Integer($N)` * It fails if the capture isn't a number, like Kernel#Integer Does anyone have a use case for returning 0 when the group isn't a number? It just seems like a "broken data" situation for no reason when e.g. using the wrong group number. ---------------------------------------- Feature #21932: `MatchData#get_int` https://bugs.ruby-lang.org/issues/21932#change-116771 * Author: nobu (Nobuyoshi Nakada) * Status: Open ---------------------------------------- This is suggested by @akr today, `$~.get_int(1)` is equivalent to `$1.to_i` but does not create the intermediate string object. https://github.com/nobu/ruby/tree/match-get_int -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/