[erlang-questions] how to add a tuple to a list.
e@REDACTED
e@REDACTED
Thu Jan 29 20:23:40 CET 2015
> Here is my code so far :
>
> -module(db).
>
> -export([new/0, destroy/1]).
>
> new() ->
> [].
>
> destroy(Db) ->
> {ok}.
>
> write(Key, Element, Db) ->
> [ [{key, data}] | Db ]
> db.erl:12: syntax error before:
well, i am not the first to notice that you have simply missed the
closing "." for the function 'write' which is a syntax error.
and this is exactly why i always put "dots" on a new line:
new() ->
[]
.
destroy(Db) ->
ok
.
write(Key, Element, Db) ->
[ {Key, Element} | Db ]
.
I also fixed some other mistakes in your snippet, look for them.
And do not forget to export your 'write/3'
'export_all' compiler's option is very nice For debugging:
-compile(export_all).
More information about the erlang-questions
mailing list