Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

String#concat

(*::string | ::Integer string_or_codepoints) -> self
concat(*objects) → string

Concatenates each object in objects to self; returns self:

Example
'foo'.concat('bar', 'baz') # => "foobarbaz"

For each given object object that is an integer, the value is considered a codepoint and converted to a character before concatenation:

Example
'foo'.concat(32, 'bar', 32, 'baz') # => "foo bar baz" # Embeds spaces.
'こん'.concat(12395, 12385, 12399)  # => "こんにちは"

Related: see Converting to New String.

See also #codepoints #count #clear #crypt also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0