Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def math(array)
end
def math(array)
first_item = array.shift
while(array.length > 0) do
second_item = array.shift
first_item = yield first_item, second_item
end
return first_item
end
def math(array)
first_item = array.shift
while(array.length > 1) do
second_item = array.shift || 0
third_item = array.shift || 0
first_item = yield first_item, second_item, third_item
end
return first_item
end
let_array = Array(0..9)
math(let_array)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.