R
rjtucke
I'm learning Ruby and was wondering if there's an elegant way to do the
following:
(Program is to print the 99 bottles of beer song, with correct english)
if num != 1
word = "bottle"
else
word = "bottles"
end
I tried to do this via word = "bottle" + ("s" unless num == 1),
but it complains about concatenating "bottle" with nil.
Thanks,
rjtucke
following:
(Program is to print the 99 bottles of beer song, with correct english)
if num != 1
word = "bottle"
else
word = "bottles"
end
I tried to do this via word = "bottle" + ("s" unless num == 1),
but it complains about concatenating "bottle" with nil.
Thanks,
rjtucke