Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Erlang
-spec square(integer()) -> integer().
square(X) when is_integer(X) -> X * X.

The guard guarantees that the return value will be an integer.
function Square (X : Integer) return Integer is
begin
   return X * X;
end Square;

New implementation...
< >
programming-idioms.org