S
Steven Jenkins
$ irb x
x(main):001:0> "This works"
=> "This works"
x(main):002:0> '22'
=> "22"
x(main):003:0> '22'.class
=> String
x(main):004:0> '22'.hex.to_s
=> "34"
x(main):005:0> "Why doesn't this?"
=> "Why doesn't this?"
x(main):006:0> '22'.sub(/(\d\d)/, "#{'\1'}")
=> "22"
x(main):007:0> '22'.sub(/(\d\d)/, "#{'\1'.class}")
=> "String"
x(main):008:0> '22'.sub(/(\d\d)/, "#{'\1'.hex.to_s}")
=> "0"
I understand everything but the last line. What am I missing?
Steve
x(main):001:0> "This works"
=> "This works"
x(main):002:0> '22'
=> "22"
x(main):003:0> '22'.class
=> String
x(main):004:0> '22'.hex.to_s
=> "34"
x(main):005:0> "Why doesn't this?"
=> "Why doesn't this?"
x(main):006:0> '22'.sub(/(\d\d)/, "#{'\1'}")
=> "22"
x(main):007:0> '22'.sub(/(\d\d)/, "#{'\1'.class}")
=> "String"
x(main):008:0> '22'.sub(/(\d\d)/, "#{'\1'.hex.to_s}")
=> "0"
I understand everything but the last line. What am I missing?
Steve