Return values in rdoc method header

The rdoc heading for Array[index] method says:

array[index] = obj → obj

and for String.new:

String.new(str="") => new_str

When I document my own classes, how do I make the part that shows return
values with the arrow appear? i.e. change_array(old_array) => new_array

I don’t know how to comment my code such that the “=> new_array” would
appear in rdoc.

Thank you.

Jason L. wrote:

The rdoc heading for Array[index] method says:

array[index] = obj → obj

and for String.new:

String.new(str="") => new_str

When I document my own classes, how do I make the part that shows return
values with the arrow appear? i.e. change_array(old_array) => new_array

I don’t know how to comment my code such that the “=> new_array” would
appear in rdoc.

Thank you.

You have to use the call-seq directive for that:

#call-seq:

my_method(str) ==> aString

my_method(str, true) ==> anInteger

#This is your normal method description.
def my_method(x, y = false)
#Here goes your code…
end


Note the empty line between the method description header and the main
description.

Marvin

Marvin Gülker wrote:

#call-seq:

Thank you. I have not yet found that in the documentation, but that
answers my question.