File: try_again.Rd

package info (click to toggle)
r-cran-testthat 3.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,452 kB
  • sloc: cpp: 9,261; ansic: 37; sh: 14; makefile: 5
file content (27 lines) | stat: -rw-r--r-- 561 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/try-again.R
\name{try_again}
\alias{try_again}
\title{Try evaluating an expressing multiple times until it succeeds.}
\usage{
try_again(times, code)
}
\arguments{
\item{times}{Maximum number of attempts.}

\item{code}{Code to evaluate}
}
\description{
Try evaluating an expressing multiple times until it succeeds.
}
\examples{
third_try <- local({
  i <- 3
  function() {
    i <<- i - 1
    if (i > 0) fail(paste0("i is ", i))
  }
})
try_again(3, third_try())
}
\keyword{internal}