制御フロー
If / Elif / Else
Section titled “If / Elif / Else”if x lt 0 console.log[///negative///]elif x eq 0 console.log[///zero///]else console.log[///positive///]Unless
Section titled “Unless”if の否定:
unless done keep-going[]if (!(done)) { keepGoing();}インラインif(三項演算子)
Section titled “インラインif(三項演算子)”const result be if condition then 1 else 2const result = condition ? 1 : 2;console.log[///debug///] if verboseconsole.log[///skip///] unless doneconsole.log[item] for item in listWhile / Until
Section titled “While / Until”while i lt 10 i be i add 1
until finished do-work[]For-in
Section titled “For-in”for item in items console.log[item]for (const item of items) { console.log(item);}インデックス付き:
for i; item in items console.log[i; item]for (let [i, item] of items.entries()) { console.log(i, item);}For-range
Section titled “For-range”for i in range 0; 10 console.log[i]for (let i = 0; i < 10; i++) { console.log(i);}Match / When
Section titled “Match / When”match x when 1 then ///one/// when 2 then ///two/// else ///other///ガード付き:
match value when n if n gt 0 console.log[///positive///] else console.log[///non-positive///]try / catch / finally
Section titled “try / catch / finally”try risky[]catch e console.log[e]finally cleanup[]式としてのtry
Section titled “式としてのtry”const result be try risky[]catch e default-valuethrow new Error[///something went wrong///]throw err if condition