I'm working through the Ruby koans and have hit one that's really confusing me.
"one two-three".gsub(/(t\w*)/) { $1[0, 1] }
=> "one t-t"
However, when I modify the return array for the $1 variable, I get a confusing result.
"one two-three".gsub(/(t\w*)/) { $1[1, 2] }
=> "one wo-hr"
Given the first result, I'd expect the second bit of code to return "one w-h". Why are two characters being returned in the second instance?