Calculate the sum of two integers a and b, without using the operator +
and -
.
1 min readMar 10, 2020
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.