Actions
Feature #21932
open`MatchData#get_int`
Feature #21932:
`MatchData#get_int`
Status:
Open
Assignee:
-
Target version:
-
Description
This is suggested by @akr (Akira Tanaka) today, $~.get_int(1) is equivalent to $1.to_i but does not create the intermediate string object.
Updated by nobu (Nobuyoshi Nakada) 4 days ago
- Description updated (diff)
Updated by zenspider (Ryan Davis) 3 days ago
Tried to add a comment to your commit but github is being very sketchy today.
In the method comment on the impl side, you have examples for parsing a date... but IDGI... 1/2/10 are supposed to be the base arg, right? Base 1?
Updated by nobu (Nobuyoshi Nakada) 3 days ago
zenspider (Ryan Davis) wrote in #note-2:
In the method comment on the impl side, you have examples for parsing a date... but IDGI... 1/2/10 are supposed to be the base arg, right? Base 1?
I can't get from where the example comes.
Do you want to mean something like this?
/\d+/.match("1/2/10").get_int(0) # => 1
/\d+/.match("1/2/10").get_int(0, 1) # invalid radix 1 (ArgumentError)
Updated by kou (Kouhei Sutou) 1 day ago
FYI: strscan will use integer_at not get_int: https://github.com/ruby/strscan/pull/192#issuecomment-4002582149
Updated by Eregon (Benoit Daloze) about 16 hours ago
- Related to Feature #21943: Add StringScanner#get_int to extract capture group as Integer without intermediate String added
Actions