This method should return the sum of all numbers between a and b (not ordered) and should return a or b if they are equal.
def get_sum(a,b)
a < b ? (a..b).sum : (b..a).sum
end
I'm curious as to why this method doesn't return nil when a and b are equal. The ternary operator takes care of the condition where a is less than or greater than b so I'm tempted to add return a if a==b before the ternary to test if they are equal but it appears it's not necessary.
For example, if a=5 and b=5 then the value returned is 5. Could someone explain why this is please?