Chapter 2
Language Basics
Variables, values, functions, conditions, loops, and scope.
Dynamic value model
HHY is dynamically typed. Runtime values include Null, Bool, Int, Float, String, List, Map, Range, DateTime, Path, Duration, Bytes, Percent, Result, Stream, and system objects.
- let declares a binding that cannot be reassigned.
- let mut declares a reassignable binding.
- Blocks, functions, and modules use lexical scope.
- Collection updates return new values; there is no in-place collection API.
Functions and control flow
fn summarize(items) {
let mut total = 0
for item in items {
if item.enabled {
total = total + item.score
}
}
return total
}
let users = [
{ name: "Ada", enabled: true, score: 98 },
{ name: "Linus", enabled: false, score: 86 }
]
summarize(users) |> printFunctions receive values and support closures. V1.0 has no overloading, generics, or default parameters.
