Re: [Bioc-devel] testing class and length of function args

2015-07-23 Thread Michael Love
Thanks all for the pointers On Jul 23, 2015 10:51 AM, "Charles C. Berry" wrote: > On Wed, 22 Jul 2015, Michael Love wrote: > > it's slightly annoying to write >> >> foo <- function(x) { >> if ( ! is.numeric(x) ) stop("x should be numeric") >> if ( ! length(x) == 2 ) stop("x should be length 2"

Re: [Bioc-devel] testing class and length of function args

2015-07-23 Thread Martin Morgan
On 07/23/2015 10:41 AM, Hervé Pagès wrote: Hi Mike, On 07/22/2015 04:13 PM, Michael Love wrote: it's slightly annoying to write foo <- function(x) { if ( ! is.numeric(x) ) stop("x should be numeric") if ( ! length(x) == 2 ) stop("x should be length 2") c(x[2], x[1]) } That's a littl

Re: [Bioc-devel] testing class and length of function args

2015-07-23 Thread Hervé Pagès
Hi Mike, On 07/22/2015 04:13 PM, Michael Love wrote: it's slightly annoying to write foo <- function(x) { if ( ! is.numeric(x) ) stop("x should be numeric") if ( ! length(x) == 2 ) stop("x should be length 2") c(x[2], x[1]) } That's a little bit kind of what stopifnot() is for: st