Odak modu
Control Structures-If Else
Code from video: https://solidity-by-example.org/if-else/
You can access the video content in Turkish prepared by İTÜ Blockchain here (between 00:00 - 18:43): https://www.youtube.com/watch?v=a9PtEe3CXSg&list=PLby2HXktGwN4Cof_6a8YwlMrboX8-hs73&index=6
This video explains how to write an if / else conditional statement in Solidity. Most of the control structures known from curly-brace languages are available in Solidity.
There is: if, else, while, do, for, break, continue, return, with the usual semantics known from C or JavaScript.
Solidity also supports exception handling in the form of try/catch-statements, but only for external function calls and contract creation calls. Errors can be created using the revert statement.
Parentheses cannot be omitted for conditionals, but curly braces can be omitted around single-statement bodies.
Note that there is no type conversion from non-boolean to boolean types as there is in C and JavaScript, so if (1) { ... } is not valid in Solidity.
There is also a shorthand way to write conditional statements using ternary operators.
Resources:
You can find detailed further information from Solidity Official documentation (in English):
https://docs.soliditylang.org/en/v0.8.15/control-structures.html
Yazılım Kariyerinde İlerlemeni Hızlandıracak Programlar
Patika+ programlarımız ile 4-8 aylık yoğun yazılım kamplarına katıl, temel bilgilerden başlayarak kapsamlı bilgiler edin, yazılım kariyerine başla!
Yorum yapabilmek için derse kayıt olmalısın!