From: chris@... Date: 2019-08-09T22:54:29+00:00 Subject: [ruby-core:94234] [Ruby master Bug#16091] gsub Issue #16091 has been updated by chrisseaton (Chris Seaton). @thiaguerd I don't understand - the `String#replace` method only takes one argument - you're calling it with two so that's not going to work for a start. Secondly, the method doesn't replace occurrences of one string with another, which is what I think you think it does. It replaces the whole string with another string. https://ruby-doc.org/core-2.6.3/String.html#method-i-replace So your code doesn't work because that's just not what this method does or is documented to do in Ruby. ---------------------------------------- Bug #16091: gsub https://bugs.ruby-lang.org/issues/16091#change-80540 * Author: thiaguerd (thiago feitosa) * Status: Feedback * Priority: Normal * Assignee: * Target version: * ruby -v: 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- ```ruby a = "test ?" b = "?" c = "\\&" a.gsub(b,c) ``` -- https://bugs.ruby-lang.org/ Unsubscribe: