You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using YARD for a ruby project, I realized that the "@return" will be documented only when an explicit return is provided in the commented function. Ruby has implicit return and I'm wondering if it wouldn't make sense to always add it in the generated snippet.
Something like:
# @return [TODO:nil]
But for this to work with ruby, it seems that Neogen should always "call" return_statement in the template instead of only when the function has an explicit return.
The text was updated successfully, but these errors were encountered:
Hello, so you are telling me that YARD should provide by default implicit returns ?
If so (I still need a source for this claim), I can make this work 😃
The following code will print "Implicit return has its good sides".
## Example method to demonstrate implicit return## @param whatever [String] text to append## @return [String] text#defexample(whatever)"Implicit return #{whatever}"endputsexample("has its good sides")
Not that the following with return something as well. There is no such thing like "no returned value" with ruby.
## Another example method to demonstrate implicit return## @return [NilClass] nil#defmuteputs"The silence is gold."nilendputsmute.inspect
... will output:
The silence is gold.
nil
However explicit returns have their use, like in most language:
## Example method to demonstrate explicit return## @param number [Integer] to test## @return [String,Integer] "hit" if multiple of 10 otherwise the original _number_ value#deftest(number)return"hit"ifnumber % 10# do stuffnumberendputstest(1)# 1putstest(20)# hit
I'm not sure that I wrote the best examples, but conventinal cases are illustrated that way. So in a nutshell, yes, ruby methods always return something.
Using YARD for a ruby project, I realized that the "@return" will be documented only when an explicit return is provided in the commented function. Ruby has implicit return and I'm wondering if it wouldn't make sense to always add it in the generated snippet.
Something like:
But for this to work with ruby, it seems that Neogen should always "call"
return_statement
in the template instead of only when the function has an explicitreturn
.The text was updated successfully, but these errors were encountered: