Inline Control Flows

array comprehensions

Syntax

"["
expression
for
(
[const | let] varname
from expression:Number
(til | to) expression:Number
[by expression:Number]
[(while | until) expression:Boolean]
[when expression:Boolean]
| [const | let] ((varname[: type] | destructuring)[, index] | :index)
in expression:Array
[desc]
[from expression:Number]
[(til | to) expression:Number]
[by expression:Number]
[(while | until) expression:Boolean]
[when expression:Boolean]
| [const | let] ((varname[: type] | destructuring)[, key] | :key)
of expression:Object
[(while | until) expression:Boolean]
[when expression:Boolean]
| [const | let] varname[, index] | :index
in operand:Number[<]..[<]operand:Number[..operand:Number]
[(while | until) expression:Boolean]
[when expression:Boolean]
)
"]"

Examples

likes = {
leto: 'spice'
paul: 'chani'
duncan: 'murbella'
}
spicyHeroes = [hero for like, hero of likes when like == 'spice']
// spicyHeroes = ['leto']
a = [i for const i from 0 to 10 by 2 until foo(i)]

assignement statement

Syntax

... = expression [
if expression:Boolean [else expression]
| unless expression:Boolean
]

Examples

y = 10 if x == 5 else 15

expression statement

Syntax

expression
[
for
(
[const | let] varname
from expression:Number
(til | to) expression:Number
[by expression:Number]
[(while | until) expression:Boolean]
[when expression:Boolean]
| [const | let] ((varname[: type] | destructuring)[, index] | :index)
in expression:Array
[desc]
[from expression:Number]
[(til | to) expression:Number]
[by expression:Number]
[(while | until) expression:Boolean]
[when expression:Boolean]
| [const | let] ((varname[: type] | destructuring)[, key] | :key)
of expression:Object
[(while | until) expression:Boolean]
[when expression:Boolean]
| [const | let] varname[, index] | :index
in operand:Number[<]..[<]operand:Number[..operand:Number]
[(while | until) expression:Boolean]
[when expression:Boolean]
)
| if expression:Boolean
| unless expression:Boolean

]

Examples

foobar() if x == 5
heroes = ['leto', 'duncan', 'goku']
console.log(hero) for hero in heroes

let statement

Syntax

let ... = expression [
if expression:Boolean [else expression]
| unless expression:Boolean
]

Examples

let y = 10 if x == 5 else 15

return statement

Syntax

return [
if expression:Boolean
| unless expression:Boolean
| expression [
if expression:Boolean [else expression]
| unless expression:Boolean
]
]

Examples

return if lang == 'en'
return 'hello' if lang == 'en' else 'bonjour'

throw statement

Syntax

throw expression [
if expression:Boolean [else expression]
| unless expression:Boolean
]

Examples

throw new Error('Not Defined') if !?x