Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

Programming 1 (BI)
  ▸ exercises
  ▸ quick link

teaching assets


Félévek

* 2025/26/2
* archívum


Linkek

* kalendárium
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C#
* D lang.
* Java
* Nim
* Nim2
  + exercises
* XC=BASIC
* old
  ✦C++, ✦Clojure, ✦Scala


[ edit | logout ]
[ sandbox | passwd ]

assert

Positive case

let x = 10

assert x == 10

Negative case

let x = 10

assert x == 5

Execution:

$ ./main
/home/jabba/Dropbox/nim/Nim-2026/a12-assert/main.nim(15) main
/home/jabba/.choosenim/toolchains/nim-2.2.8/lib/std/assertions.nim(45) failedAssertImpl
/home/jabba/.choosenim/toolchains/nim-2.2.8/lib/std/assertions.nim(40) raiseAssert
/home/jabba/.choosenim/toolchains/nim-2.2.8/lib/system/fatal.nim(62) sysFatal
Error: unhandled exception: /home/jabba/Dropbox/nim/Nim-2026/a12-assert/main.nim(15, 1) `x == 5`
[AssertionDefect]

Optionally, you can add a message too:

let x = 10

assert x == 5, "x should be 5"

Execution:

$ ./main
...
Error: unhandled exception: .../nim/Nim-2026/a12-assert/main.nim(15, 1) `x == 5` x should be 5
[AssertionDefect]

Notice that the message "x should be 5" is also printed.

Ignore the assert lines

To ignore assert statements, compile with the --assertions:off flag or the -d:danger definition.

Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2026 May 01, 08:10