% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/arg_equal.R
\name{arg_equal}
\alias{arg_equal}
\alias{arg_not_equal}
\title{Check Equal Arguments}
\usage{
arg_equal(
  x,
  x2,
  ...,
  .arg = rlang::caller_arg(x),
  .arg2 = rlang::caller_arg(x2),
  .msg = NULL,
  .call
)

arg_not_equal(
  x,
  x2,
  ...,
  .arg = rlang::caller_arg(x),
  .arg2 = rlang::caller_arg(x2),
  .msg = NULL,
  .call
)
}
\arguments{
\item{x, x2}{the objects to compare with each other.}

\item{\dots}{other arguments passed to \code{\link[=all.equal]{all.equal()}}.}

\item{.arg, .arg2}{the names of the objects being compared; used in the error message if triggered. Ignored if \code{.msg} is supplied.}

\item{.msg}{an optional alternative message to display if an error is thrown instead of the default message.}

\item{.call}{the execution environment of a currently running function, e.g. \code{.call = rlang::current_env()}. The corresponding function call is retrieved and mentioned in error messages as the source of the error. Passed to \code{\link[=err]{err()}}. Set to \code{NULL} to omit call information. The default is to search along the call stack for the first user-facing function in another package, if any.}
}
\value{
Returns \code{NULL} invisibly if an error is not thrown.
}
\description{
Checks whether two arguments are equal (\code{arg_equal()}) or not equal (\code{arg_not_equal()}).
}
\details{
Tests for equality are performed by evaluating whether \code{isTRUE(all.equal(x, x2, ...))} is \code{TRUE} or \code{FALSE}.
}
\examples{
f <- function(x, y, ...) {
  arg_equal(x, y, ...)
}

try(f(x = 1, y = 1))      ## No error
try(f(x = 1L, y = 1.0))   ## No error despite type difference
try(f(x = 1, y = 1.00001, ## No error, within tolerance
      tolerance = .001))

try(f(x = 1, y = 2))       ## Error: different
try(f(x = 1, y = 1.00001)) ## Error

g <- function(x, y, ...) {
  arg_not_equal(x, y, ...)
}

try(g(x = 1, y = 1)) ## Error
try(g(x = 1, y = 2)) ## No error
}
\seealso{
\code{\link[=all.equal]{all.equal()}}
}
