I am trying to create a function that checks for strict equality and I would like to use the triple equal sign. Some context:
> 3 == '3'
[1] TRUE
> FALSE == 0
[1] TRUE
All of the above check returns TRUE
because the inputs are coerced to a common type. However I want to check for strict equality. The identical
function does exactly what I need.
> identical(3,'3')
[1] FALSE
> identical(FALSE, 0)
[1] FALSE
Now I want to implement this in a more concise and less verbose way. As in Javascript I would like to use the triple equal sign. I wrote this function:
`===` <- function(a,b){
identical(a,b)
}
However this doesn't behave as expected:
> 3 === 3
Error: unexpected '=' in "3 ==="
What am I missing? Thank you