Skip to content

Instantly share code, notes, and snippets.

@mistyrinth
Created November 29, 2018 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mistyrinth/97cb54e720f361fcf173539f602139b4 to your computer and use it in GitHub Desktop.
Save mistyrinth/97cb54e720f361fcf173539f602139b4 to your computer and use it in GitHub Desktop.
array = ["りんご", "みかん", "ぶどう"]
puts "元の配列は #{array} です"
# 要素の置き換え
array[1..2] = ["いちご", "さくらんぼ", "もも"]
puts "置き換えた後の配列は #{array} です"
# 要素の追加
array[1,0] = ["なし"]
puts "追加した後の配列は #{array} です"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment