Friday, May 17, 2013

string constant

What's a point of using string constants in this Ruby code?
ANIMAL3 = 'rat'
ANIMAL6 = 'rabbit'
def animal3to6(animal)
  length = animal.length
  if length > 6
    return ANIMAL6
  elsif length < 3
    return ANIMAL3
  else
    return animal
  end
end

No comments:

Post a Comment