From: hanmac@... Date: 2017-10-18T12:41:45+00:00 Subject: [ruby-core:83336] [Ruby trunk Feature#14022] String#surround Issue #14022 has been updated by Hanmac (Hans Mackowiak). +1 i thought i have seen something like that before, but i don't remember where ah now i remember, it was for JQuery#wrap http://api.jquery.com/wrap/ i think such a surround method might be used for xml stuff and other similar ones ---------------------------------------- Feature #14022: String#surround https://bugs.ruby-lang.org/issues/14022#change-67296 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- After joining the elements of an array into a string using `Array#join`, I frequently need to put substrings before and after the string. In such case, I would have to use either of the following: ```ruby [1, 2, 3].join(", ").prepend("<").concat(">") # => "<1, 2, 3>" "<#{[1, 2, 3].join(", ")}>" # => "<1, 2, 3>" "<" + [1, 2, 3].join(", ") + ">" # => "<1, 2, 3>" ``` but none of them is concise enough. I wish there were `String#surround` that works like this: ```ruby [1, 2, 3].join(", ").surround("<", ">") # => "<1, 2, 3>" ``` -- https://bugs.ruby-lang.org/ Unsubscribe: