diff --git a/index.html b/index.html index a955019..adc14ac 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@ - + @@ -157,6 +157,25 @@ greet: (name) { greet("Orion") \`\`\` +## Arrow Blocks + +To enhance conciseness, Hi adopts the \`=>\` ("fat arrow") from JavaScript for single-expression blocks. This provides a shorthand for a block that immediately returns the value of its expression, perfect for callbacks and functional patterns. + +It's a direct replacement for \`(params) { ^ expression }\`. + +\`\`\`javascript +// Standard block +add: (a, b) { ^ a + b } + +// Equivalent Arrow Block +add: (a, b) => a + b + +// Useful for functional helpers +numbers: [1, 2, 3] +doubled: numbers.map((n) => n * 2) +_(doubled) // [2, 4, 6] +\`\`\` + ## Booleans and Equality Hi dispenses with boolean keywords in favor of canonical numeric values for truthiness.