Files
ruby-examples-1/level3/24.rb
2026-01-15 14:01:21 +09:00

16 lines
233 B
Ruby
Executable File

#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
배열의 짝수만 출력
=end
arr = [5, 7, 4, 3, 2, 9, 1, 6]
arr.each do |num|
puts num if num.even?
end
# select 필터 사용
arr.select { |v| v.even? }
.each { |v| puts v }