What does the expression mean (...)?

0

I could not figure out what the expression !(...) means

Example:

if (!(book %in% books))
    stop("Unknown book")
    
asked by anonymous 09.04.2018 / 22:30

2 answers

4

Anything you put inside an if ("Anything") will be converted to true or false. The if body only executes if the result is true.

In your case as there is the character '!' indicates a denial of the IF, ie "No Se"

Your expression means:

  

If there is NO book in the collection of books do

     

Stop the execution of the expression and display a message (which in your case   will be: "Unknown book")

In short, your function is looking for a book in a list, and if it does not find it returns a message.

    
10.04.2018 / 13:34
2

It is a binary logic operator. It has the function of negation, knowledge as not . It denies the return of the underlying term. If the return is verdadeiro the ! operator will render the expression as falsa .

The language looks like R.

    
10.04.2018 / 12:47