published under license CC4-BY
posted in category Software Development & Programming / Ruby
posted at 08. Mar '24
Ruby: string not matched (IndexError)
You probably expected the variable to be a hash, but it is a string.
irb(main):010> x = "123"
=> "123"
irb(main):011> x["12"] = "abc"
=> "abc"
irb(main):012> x
=> "abc3"
irb(main):013> x["12"] = "abc"
(irb):13:in `[]=': string not matched (IndexError)
[]=
allows to replace substring with another string, even with a different size.
Add Comment