Syntax error for inet parse_address command in elixir

1k views Asked by At

I am new to elixir. My task to check if the given string is an ip address or a number. I found that inet has this parse_address which checks if the given string is an ip address or not and provides the appropriate response.

My code on the iex terminal is as follows

inet :parse_address("192.168.42.2")

When I run the above code on the terminal I get the following error

 iex(1)> inet :parse_address("192.168.42.2").
 ** (SyntaxError) iex:1: syntax error before: '('

Can somebody help me with this issue?

1

There are 1 answers

2
NoDisplayName On BEST ANSWER

It should be

:inet.parse_address('192.168.42.2')

because module names are just atoms but in erlang, they start with a lowercase letter.

There is a lot of articles covering the subject on Erlang interoperability, one of those is here -> https://elixirschool.com/en/lessons/advanced/erlang/