Asserts that the [code]condition[/code] is [code]true[/code]. If the [code]condition[/code] is [code]false[/code], an error is generated. When running from the editor, the running project will also be paused until you resume it. This can be used as a stronger form of [method push_error] for reporting errors to project developers or add-on users. [b]Note:[/b] For performance reasons, the code inside [method assert] is only executed in debug builds or when running the project from the editor. Don't include code that has side effects in an [method assert] call. Otherwise, the project will behave differently when exported in release mode. The optional [code]message[/code] argument, if given, is shown in addition to the generic "Assertion failed" message. You can use this to provide additional details about why the assertion failed. [codeblock] # Imagine we always want speed to be between 0 and 20. var speed = -10 assert(speed < 20) # True, the program will continue assert(speed >= 0) # False, the program will stop assert(speed >= 0 and speed < 20) # You can also combine the two conditional statements in one check assert(speed < 20, "speed = %f, but the speed limit is 20" % speed) # Show a message with clarifying details [/codeblock]
[code]koşul[/code] durumunun [code]doğru[/code] olduğunu test eder. [code]koşul[/code] eğer [code]yanlış[/code] ise, bir hata mesajı verilir ve siz devam edene kadar durur. Bu yalnızca hata ayıklama modunda çalışır, ya da oyunu editorden çalıştırdığınızda çalışır. Hata ayıklama amacı ile geliştirme esnasında [code]doğru[/code] koşulun oluşup oluşmadığını takip etmek üzere kullanın. Opsiyonel [code]mesaj[/code] argümanı, varsa, genel "Assertion failed" hata mesajına ek olarak gösterilir. Bu ek mesaj kısmını hata hakkında aydınlatıcı metin olarak kullanabilirsiniz. [codeblock] # hızı daima 0 ile 20 arasında tutmak istediğimiz bir durumu hayal edin speed = -10 assert(speed < 20) # Doğru, program çalışmaya devam eder assert(speed >= 0) # Yanlış, program durur assert(speed >= 0 && speed < 20) # aynı zamanda eğer istersen iki koşul durumunu birleştirerek de sınama yapabilirsin assert(speed < 20, "hız = %f, fakat hız limiti 20" % speed) # detayları açıklayan bir de mesaj ekleyin [/codeblock]
[b]Note:[/b] For performance reasons, the code inside [method assert] is only executed in debug builds or when running the project from the editor. Don't include code that has side effects in an [method assert] call. Otherwise, the project will behave differently when exported in release mode.
The optional [code]message[/code] argument, if given, is shown in addition to the generic "Assertion failed" message. You can use this to provide additional details about why the assertion failed.
[codeblock]
# Imagine we always want speed to be between 0 and 20.
var speed = -10
assert(speed < 20) # True, the program will continue
assert(speed >= 0) # False, the program will stop
assert(speed >= 0 and speed < 20) # You can also combine the two conditional statements in one check
assert(speed < 20, "speed = %f, but the speed limit is 20" % speed) # Show a message with clarifying details
[/codeblock]
Opsiyonel [code]mesaj[/code] argümanı, varsa, genel "Assertion failed" hata mesajına ek olarak gösterilir. Bu ek mesaj kısmını hata hakkında aydınlatıcı metin olarak kullanabilirsiniz.
[codeblock]
# hızı daima 0 ile 20 arasında tutmak istediğimiz bir durumu hayal edin
speed = -10
assert(speed < 20) # Doğru, program çalışmaya devam eder
assert(speed >= 0) # Yanlış, program durur
assert(speed >= 0 && speed < 20) # aynı zamanda eğer istersen iki koşul durumunu birleştirerek de sınama yapabilirsin
assert(speed < 20, "hız = %f, fakat hız limiti 20" % speed) # detayları açıklayan bir de mesaj ekleyin
[/codeblock]