harrylaou (2) [Avatar] Offline
#1
Is it a good idea to include return types in all sample code?

for example

def getMarketValue(e: Equity, a: BigDecimal) = //..
def getAccruedInterest(i: String) = //..

to become

def getMarketValue(e: Equity, a: BigDecimal) :XXX= //..
def getAccruedInterest(i: String):XXX = //..


For me it is always clearer when I read code , I get the function signature at once.
Debasish Ghosh (113) [Avatar] Offline
#2
At least for public API I think it's an essential practice to include the return types. For some very obvious methods they may be omitted, but a must for non trivial methods. I have a plan to include all of them before the book is released. Marking this post as an issue on Github.

Thanks.