|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching * Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
if-elif-elseLike in Python.
Output: negative zero positive The if expressionAn let n = 9 let status = if n < 0: "negative" elif n == 0: "zero" else: "positive" echo status # positive Let's simplify it a bit: let n = 9 let status = if n < 0: "negative" else: "zero or positive" echo status # zero or positive It can be written in various ways. All these three variations are equivalent:
# v3 let n = 9 let status = if n < 0: "negative" else: "zero or positive" echo status # zero or positive 𝥶This is the simplest form and this is how you can have a ternary operator in Nim :) |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |
||||||