Results 1 to 5 of 5
  1. #1
    newmember is offline Member
    Join Date
    Dec 2007
    Posts
    8
    Rep Power
    0

    Default [SOLVED] about Assertion...

    Could any one please explain, Difference between using If condition and Assertion


    thank you.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    In common way, both are test the true-false status in a pre-define condition. But there is a difference. We call assertion is a predicate placed in a program, that means assertions are placed to indicate/notify that developers think it's always true. It give an assertion failiar exception if the test is false, not like in 'if' condition. If the 'if' condition is false you you can do other process. Generally assertions are use in development process only.

  3. #3
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default

    Yes what eranga said was rite..
    While using assertion if the result is false the whole process is terminated.
    and while using if condition,if result is false it executes according to condition given or continue with code after if stmt.
    To finish sooner, take your own time....
    Nivedithaaaa

  4. #4
    newmember is offline Member
    Join Date
    Dec 2007
    Posts
    8
    Rep Power
    0

    Default

    yeah thanks, now i understood. it mostly used in a development phase. where i would want my application stops if any error occurs. but i can disable it at the time of distributing it.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by newmember View Post
    yeah thanks, now i understood. it mostly used in a development phase. where i would want my application stops if any error occurs. but i can disable it at the time of distributing it.
    Yes you must disable all assertion in distribution.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •