Ensure arg is valid
assert  arg (anything)
Raises an exception if the argument is either nil or false.
Introduced in v2.8
Examples
 
  | # Example 1 | 
  | 
assert true  
assert 1     
assert "foo"
assert false 
 | 
# Simple assertions
# As true is neither nil or false, this assertion passes
# Similarly, 1 passes
# As do string
# This will raise an exception
 | 
 
  | # Example 2 | 
  | 
assert false, "oops"
 | 
# Communicating error messages
# This will raise an exception containing the message "oops"
 | 
 
  | # Example 3 | 
  | 
assert (1 + 1) == 2
assert [:a, :b, :c].size == 3
 | 
# More interesting assertions
# Ensure that arithmetic is sane!
# ensure lists can be correctly counted
 |