<FromGitter>
<yxhuvud> Heh. Typing columns(matrix).map |column| do instead of columns(matrix).map do |column| does interesting things to the parser/formatter
<dbell>
/([LR])([0-9]+)/.match(step) {|md| p md.class} 'Regex#match' is not expected to be invoked with a block, but a block was given
<dbell>
this is a secondary error, which I ran into while trying to figure out why my match data always presents as nil
<dbell>
step="R3"
<dbell>
m = /([LR])([0-9]+)/.match(step)
<dbell>
p m
<dbell>
=> #<Regex::MatchData "R3" 1:"R" 2:"3">
<dbell>
p m[1]
<dbell>
=> Error in line 4: undefined method '[]' for Nil (compile-time type is (Regex::MatchData | Nil))
<FromGitter>
<johnjansen> yeah, looks like its not defined with a block on the string class (which is an omission) ⏎ you can use scan however https://play.crystal-lang.org/#/r/1fnc
<dbell>
so the docs are wrong?
<BlaXpirit>
dbell, docs for matchdata are wrong, yes
<BlaXpirit>
so, what are you trying to do?
<BlaXpirit>
do some action if there is a match?
<dbell>
are the docs the intended behaviour, and this is a code error?
<FromGitter>
<david50407> @johnjansen but it compiled
<FromGitter>
<johnjansen> he wants an each_match, ala scan
<BlaXpirit>
docs are not intended behavior, possibly old behavior
<BlaXpirit>
sorry, i was unable to guess >_>
<FromGitter>
<david50407> so this is a bug if the compiler should throw an error
<dbell>
basically, trying to figure out why my match returns a MatchData object, but all queries to the resulting object behave as if its nil
<dbell>
there are two issues, the block one does throw an error
<FromGitter>
<johnjansen> it didn’t compile in playground
pawnbox has quit [Remote host closed the connection]
<BlaXpirit>
dbell, `match` might return MatchData or nil
<FromGitter>
<david50407> sorry I'm talking about the splat type vars
<dbell>
the original issue I was having is that block of code above
<BlaXpirit>
it happened to return MatchData this time, but that is not known
<dbell>
ah, so how do I protect the code during compile time so that I can retrieve the match data?
<BlaXpirit>
dbell, that's all described in the great docs
<dbell>
you mean the docs that are wrong?
<BlaXpirit>
dbell, that's API docs
<BlaXpirit>
to do some action if there is a match: `if "asdf" =~ /(.)sd./; matchdata = $~; first_bracket = $1; end`
<dbell>
do you mind if I update the API docs to match current behaviour?
<BlaXpirit>
dbell, that would be nice, you can make a pull request
snsei has joined #crystal-lang
<dbell>
will do; I'm super excited with the prospect of Crystal and would love to help it be successful
<Yxhuvud>
I prefer x = /foo/.match "foo"; if x; do_something_with(x[1])
* dbell
is 10+ years of Ruby, Engine Yard alumni
<dbell>
thanks all
snsei has quit [Ping timeout: 268 seconds]
vivus-ignis has quit [Quit: vivus-ignis]
pawnbox has joined #crystal-lang
vivus-ignis has joined #crystal-lang
<dbell>
BlaXpirit: looks like Ary Borenszweig updated those docs on Nov 29th.
<crystal-gh>
[crystal] luislavena opened pull request #3646: Includes debug flag when compiling in debug mode (master...add-debug-to-flags) https://git.io/v1RSe
soveran has quit [Remote host closed the connection]
mark_66 has quit [Remote host closed the connection]
soveran has joined #crystal-lang
ltran has joined #crystal-lang
akwiatkowski has quit [Ping timeout: 264 seconds]
sp4rrow has joined #crystal-lang
sp4rrow has quit [Read error: Connection reset by peer]