Calculate the sum of two integers a and b, without using the operator + and -.

This should probably be solved using bitwise operators but here’s a quick solution using the sum method on arrays.

def get_sum(a, b)
[a,b].sum
end

We simply call the sum method on the numbers we are adding after turning them into an array.

Full-stack Engineer. Rails/Node.js/React. I love plantain chips! Reach me at Adebola.dev.