Skip to content

Instantly share code, notes, and snippets.

@panchiga
Last active August 29, 2015 14:22
Show Gist options
  • Save panchiga/56ee98442dc747b26f67 to your computer and use it in GitHub Desktop.
Save panchiga/56ee98442dc747b26f67 to your computer and use it in GitHub Desktop.
arr = [1,2,3,4]
#配列の要素が2か3にマッチしたら配列中のそれを消去
arr.each do |item|
if ((item == 2) || (item == 3))
arr.delete(item)
end
end
#2と3を消去後の配列の出力
arr.each do |item|
print item," "
end
puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment