class Array
def my_map(&block)
new_array = []
self.each do |e|
new_array << block.call(e)
# new_array << yield(e)
end
new_array
end
def my_select
new_arr = []
self.each do |e|
new_arr << e if yield(e)
end
new_arr
end
end
网友评论