Expressions
case .. of
The case
expression in Hamler is the same as Haskell.
Hamler:
data RGB = Red | Green | Blue
color = Green
case color of
Red -> "Red"
Green -> "Green"
Blue -> "Blue"
case
expression in Erlang ends with an end
keyword.
Erlang:
Color = green.
case Color of
red -> "Red";
green -> "Green";
blue -> "Blue"
end.
if .. then .. else
Hamler:
-- Every `then` must have a corresponding `else`
max x y = if x > y then x else y
Erlang:
max(X, Y) -> if X > Y -> X; true -> Y end.
let and where bindings
There are no let
and where
bindings in Erlang
Hamler:
let n = 1 + 2
z = let x = 3
y = 2 * x
in x * y
-- or
z = x * y
where
x = 3
y = 5
当前内容版权归 hamler-lang 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 hamler-lang .