Assign greater of two ints?

Is there a more concise way to write this?

a = 5
b = “test123”
if a < b.length
a = b.length
end

–or–

a = b.length if a < b.length

Earle

a = b.length if a < b.length
a = [a, b.length].max

  • donald

Ball, Donald A Jr (Library) wrote:

a = b.length if a < b.length
a = [a, b.length].max

  • donald

Excellent. Thanks.

Earle