On Sun, Oct 7, 2012 at 9:39 PM, Richard D. <lists / ruby-forum.com> wrote:
> def roman num
>   roman = '' #assuming creating roman variable that's empty
>   roman = roman + 'M' * (num/1000) #adding Ms to roman variable
>   roman = roman + 'D' * (num%1000/500)
>   roman = roman + 'C' * (num%500/100)
>   roman = roman + 'L' * (num%100/50)
>   roman = roman + 'X' * (num%50/10)
>   roman = roman + 'V' * (num%10/5)
>   roman = roman + 'I' * (num%5/1)
>
>   roman # don't understand purpose of line
> end

[snip]

> I don't know what the "roman" at the end of the method does.  When
> removed, I get the same results.
>
> Thanks for the help in advance.

The method returns the result of the last statement. So, in your case,
you could leave it out. But you want to get in the habit of
specifically returning what you want, because some statements do not
return what you expect...

def remove_from object_array object
 object_array.delete(object)
end

...returns the object deleted, not the new array.

def remove_from object_array object
 object_array.delete(object)
 object_array
end

..returns the new array

Putting object where object_array is to return the object and not the
array may seem redundant, but sacrifices little to no overhead or
brevity for clarity.