Skip to content

Instantly share code, notes, and snippets.

@panchiga
Created May 30, 2015 15:00
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 panchiga/78fc964f3e034b8b0d81 to your computer and use it in GitHub Desktop.
Save panchiga/78fc964f3e034b8b0d81 to your computer and use it in GitHub Desktop.
arr = [1,2,3,4]
#配列の要素が2か3にマッチしたら配列中のそれを消去
arr.reverse_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