Created
May 30, 2015 15:00
-
-
Save panchiga/78fc964f3e034b8b0d81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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