-
[Ruby] .map // .selectcoding for food 2022. 8. 6. 03:40# Array-Giving Enumerables# map# select
arr = ["a", "b", "c", "d"] new_arr = arr.map { |ele| ele.upcase + "!" } print new_arr ----------------------------- #=> ["A!", "B!", "C!", "D!"]
num = [1,2,3,4,5,6] new_num = num.select { |ele| ele % 2 == 0 } print new_num -------------------- #=> [2, 4, 6]