Generation

generate functionSun, 13 Nov 2022

add two to all number in a list returning a newly allocated list

def add_two(list) return list.map { |x| x+2 } end add_two([1, 2, 3])

Questions about programming?Chat with your personal AI assistant