Vitaly
Vitaly

Reputation: 145

Why can't I compile my Erlang code

I have single file in my folder:

test.erl

But I can't compile my module:

test.erl:8: syntax error before: 
test.erl:2: function area/1 undefined

This is how I try to compile my test.erl file:

erlc ./test.erl

test.erl contains these lines:

-module(test).
-export([area/1]).

% comment

area({triangle, A, B, C}) ->
    S = (A + B + C) / 2,
    math:sqrt(S*(S-A)*(S-B)*(S-C));

What am I doing wrong?

Upvotes: 1

Views: 156

Answers (1)

choroba
choroba

Reputation: 241738

You ended the definition of the area with a semicolon. A complete definition must end with a dot, though.

Upvotes: 5

Related Questions