LuaNET, the lua 5.1 api documentation!

Lua-Api

Core

[LUA 5.1] assert

function assert ( v, message )
Issues an error when the value of its argument v is false (i.e., nil or false); otherwise, returns all its arguments. message is an error message; when absent, it defaults to "assertion failed!".

Comments

Example for assert

April 24, 2008, 02:27:02 PM, krishnasaradhi
 can you give me an example where we use assert function ..........

Example for assert

July 18, 2008, 06:38:17 PM, RoLex
textfile = assert (io.open ("example.txt", "w"))

assert can be used for example when trying to open a file for writing, if file doesn't exist, it will be automatically created.
© 2007 DracoBlue :: Valid XHTML, CSS, RSS Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC | SourceNet © 2007, DracoBlue :: Page created in 0.308 seconds with 99 queries.