assert is similar to throwing an exception if a given condition isn't true. An important difference is that assert statements get ignored if you compile your code with the optimization option.
To know more about this you can have a look at the following video tutorial:-