Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String#insertの説明を修正 #2925

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions refm/api/src/_builtin/String
Original file line number Diff line number Diff line change
Expand Up @@ -1814,20 +1814,24 @@ offset が負の場合、文字列の末尾から数えた位置から探索し
#@end
--- insert(pos, other) -> self

文字列 other を self に挿入して self を返します。
pos が正の場合、other を開始インデックスに挿入します。

#@samplecode 例
'foo'.insert(1, 'bar') # => "fbaroo"
#@end

pos が負の場合、self の末尾から逆方向に数えて pos+1 (self[index] の後) に other を挿入します。
pos 番目の文字の直前に文字列 other を挿入します。
self[pos, 0] = other と同じ操作です。

@param pos 文字列を挿入するインデックス
@param other 挿入する文字列

#@samplecode 例
str = "foobaz"
str.insert(3, "bar")
p str # => "foobarbaz"
'foo'.insert(-2, 'bar') # => "fobaro"
#@end

@see [[m:String#[]=]]

--- intern -> Symbol
--- to_sym -> Symbol

Expand Down