magik of R implicit return [R for BE/BA]

posted by ElMaestro  – Denmark, 2019-04-27 20:34 (721 d 14:30 ago) – Posting: # 20254
Views: 4,818

Hi all,

"smart" lost this round.

I always use explicit return(something) in my functions, when they are supposed to return a value regardless of whether it is a list, numeric, NULL or data frame some other thingy.

Yes, that involves tapping a few times more on the keyboard but it does solve a lot of problems and best of all, it makes code readable.

In language like C you would never run into this phenomenon. You declare explicitly which type the function returns and you will be bombarded with errors or warnings if you fail to return the right type of if you forget the return statement. I find it very comfortable.

Pass or fail!
ElMaestro

Complete thread:

Activity
 Admin contact
21,419 posts in 4,475 threads, 1,509 registered users;
online 13 (0 registered, 13 guests [including 2 identified bots]).
Forum time: Sunday 11:05 UTC (Europe/Vienna)

Nothing fails like success because you do not learn anything from it.
The only thing we ever learn from is failure.
Success only confirms our superstitions.    Kenneth E. Boulding

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5